Class: Brujula::BasicType
- Inherits:
-
Object
- Object
- Brujula::BasicType
- Defined in:
- lib/brujula/basic_type.rb
Instance Attribute Summary collapse
-
#as ⇒ Object
readonly
Returns the value of attribute as.
-
#data ⇒ Object
readonly
Returns the value of attribute data.
-
#name ⇒ Object
readonly
Returns the value of attribute name.
-
#parent ⇒ Object
readonly
Returns the value of attribute parent.
Instance Method Summary collapse
- #expand ⇒ Object
-
#initialize(parent: nil, data:, name:, as:) ⇒ BasicType
constructor
A new instance of BasicType.
Constructor Details
#initialize(parent: nil, data:, name:, as:) ⇒ BasicType
Returns a new instance of BasicType.
9 10 11 12 13 14 |
# File 'lib/brujula/basic_type.rb', line 9 def initialize(parent: nil, data:, name:, as:) @parent = parent @data = data @name = name @as = as end |
Instance Attribute Details
#as ⇒ Object (readonly)
Returns the value of attribute as.
7 8 9 |
# File 'lib/brujula/basic_type.rb', line 7 def as @as end |
#data ⇒ Object (readonly)
Returns the value of attribute data.
7 8 9 |
# File 'lib/brujula/basic_type.rb', line 7 def data @data end |
#name ⇒ Object (readonly)
Returns the value of attribute name.
7 8 9 |
# File 'lib/brujula/basic_type.rb', line 7 def name @name end |
#parent ⇒ Object (readonly)
Returns the value of attribute parent.
7 8 9 |
# File 'lib/brujula/basic_type.rb', line 7 def parent @parent end |
Instance Method Details
#expand ⇒ Object
16 17 18 19 20 21 22 23 24 25 26 27 28 29 |
# File 'lib/brujula/basic_type.rb', line 16 def case as when :boolean, :number, :any data else base_class.new(normalized_data).tap do |instance| instance.extend(BasicTypeMixin) instance.define_singleton_method :parent do instance_variable_get("@parent") end instance.instance_variable_set("@name", name) end end end |