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.
65 66 67 68 69 |
# File 'lib/ree/dsl/import_dsl.rb', line 65 def initialize(name) @name = name @as = nil @constants = [] end |
Instance Attribute Details
#constants ⇒ Object (readonly)
Returns the value of attribute constants.
63 64 65 |
# File 'lib/ree/dsl/import_dsl.rb', line 63 def constants @constants end |
#name ⇒ Object (readonly)
Returns the value of attribute name.
63 64 65 |
# File 'lib/ree/dsl/import_dsl.rb', line 63 def name @name end |
Instance Method Details
#&(obj) ⇒ Object
71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 |
# File 'lib/ree/dsl/import_dsl.rb', line 71 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
92 93 94 95 96 97 98 99 100 101 102 103 104 |
# File 'lib/ree/dsl/import_dsl.rb', line 92 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
88 89 90 |
# File 'lib/ree/dsl/import_dsl.rb', line 88 def get_as @as end |