Class: Ree::ImportDsl::ClassConstant
- Defined in:
- lib/ree/dsl/import_dsl.rb
Instance Attribute Summary collapse
-
#constants ⇒ Object
readonly
Returns the value of attribute constants.
-
#name ⇒ Object
readonly
Returns the value of attribute name.
Instance Method Summary collapse
- #&(obj) ⇒ Object
- #as(obj) ⇒ Object
- #get_as ⇒ Object
-
#initialize(name) ⇒ ClassConstant
constructor
A new instance of ClassConstant.
Constructor Details
#initialize(name) ⇒ ClassConstant
Returns a new instance of ClassConstant.
80 81 82 83 84 |
# File 'lib/ree/dsl/import_dsl.rb', line 80 def initialize(name) @name = name @as = nil @constants = [] end |
Instance Attribute Details
#constants ⇒ Object (readonly)
Returns the value of attribute constants.
78 79 80 |
# File 'lib/ree/dsl/import_dsl.rb', line 78 def constants @constants end |
#name ⇒ Object (readonly)
Returns the value of attribute name.
78 79 80 |
# File 'lib/ree/dsl/import_dsl.rb', line 78 def name @name end |
Instance Method Details
#&(obj) ⇒ Object
86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 |
# File 'lib/ree/dsl/import_dsl.rb', line 86 def &(obj) if !obj.is_a?(ClassConstant) raise Ree::ImportDsl::UnlinkConstError.new(obj) end new_obj = if obj.is_a?(Class) ClassConstant.new(obj.to_s.split("::").last) else obj end return self if @constants.detect { |_| _.name == new_obj.name } @constants.push(new_obj) self end |
#as(obj) ⇒ Object
107 108 109 110 111 112 113 114 115 116 117 118 119 |
# File 'lib/ree/dsl/import_dsl.rb', line 107 def as(obj) if !obj.is_a?(ClassConstant) raise Ree::ImportDsl::UnlinkConstError.new(obj) end @as = if obj.is_a?(Class) ClassConstant.new(obj.to_s.split("::").last) else obj end self end |
#get_as ⇒ Object
103 104 105 |
# File 'lib/ree/dsl/import_dsl.rb', line 103 def get_as @as end |