Class: Kamakura::Attribute
- Inherits:
-
Object
- Object
- Kamakura::Attribute
- Defined in:
- lib/kamakura/attribute.rb
Instance Attribute Summary collapse
-
#key ⇒ Object
readonly
Returns the value of attribute key.
-
#name ⇒ Object
readonly
Returns the value of attribute name.
-
#options ⇒ Object
readonly
Returns the value of attribute options.
-
#type ⇒ Object
readonly
Returns the value of attribute type.
Instance Method Summary collapse
-
#initialize(name, type, key: nil, **options) ⇒ Attribute
constructor
A new instance of Attribute.
- #parse(value) ⇒ Object
Constructor Details
#initialize(name, type, key: nil, **options) ⇒ Attribute
Returns a new instance of Attribute.
8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 |
# File 'lib/kamakura/attribute.rb', line 8 def initialize(name, type, key: nil, **) @name = name.to_sym @key = key ? key.to_sym : @name @options = if type.is_a?(Array) if value_type = Kamakura.lookup_value_type(type[0]) @type = CollectionType.new(value_type) else @type = CollectionType.new(type[0]) end elsif value_type = Kamakura.lookup_value_type(type) @type = value_type else @type = type end end |
Instance Attribute Details
#key ⇒ Object (readonly)
Returns the value of attribute key.
6 7 8 |
# File 'lib/kamakura/attribute.rb', line 6 def key @key end |
#name ⇒ Object (readonly)
Returns the value of attribute name.
6 7 8 |
# File 'lib/kamakura/attribute.rb', line 6 def name @name end |
#options ⇒ Object (readonly)
Returns the value of attribute options.
6 7 8 |
# File 'lib/kamakura/attribute.rb', line 6 def @options end |
#type ⇒ Object (readonly)
Returns the value of attribute type.
6 7 8 |
# File 'lib/kamakura/attribute.rb', line 6 def type @type end |
Instance Method Details
#parse(value) ⇒ Object
26 27 28 |
# File 'lib/kamakura/attribute.rb', line 26 def parse(value) @type.parse(value, @options) end |