Class: Rasti::Model::Attribute
- Inherits:
-
Object
- Object
- Rasti::Model::Attribute
- Defined in:
- lib/rasti/model/attribute.rb
Instance Attribute Summary collapse
-
#name ⇒ Object
readonly
Returns the value of attribute name.
-
#type ⇒ Object
readonly
Returns the value of attribute type.
Instance Method Summary collapse
- #default? ⇒ Boolean
- #default_value ⇒ Object
-
#initialize(name, type, options = {}) ⇒ Attribute
constructor
A new instance of Attribute.
- #option(name) ⇒ Object
- #to_s ⇒ Object (also: #inspect)
Constructor Details
#initialize(name, type, options = {}) ⇒ Attribute
Returns a new instance of Attribute.
7 8 9 10 11 |
# File 'lib/rasti/model/attribute.rb', line 7 def initialize(name, type, ={}) @name = name @type = type @options = end |
Instance Attribute Details
#name ⇒ Object (readonly)
Returns the value of attribute name.
5 6 7 |
# File 'lib/rasti/model/attribute.rb', line 5 def name @name end |
#type ⇒ Object (readonly)
Returns the value of attribute type.
5 6 7 |
# File 'lib/rasti/model/attribute.rb', line 5 def type @type end |
Instance Method Details
#default? ⇒ Boolean
13 14 15 |
# File 'lib/rasti/model/attribute.rb', line 13 def default? .key? :default end |
#default_value ⇒ Object
17 18 19 |
# File 'lib/rasti/model/attribute.rb', line 17 def default_value .fetch(:default) end |
#option(name) ⇒ Object
21 22 23 |
# File 'lib/rasti/model/attribute.rb', line 21 def option(name) [name] end |
#to_s ⇒ Object Also known as: inspect
25 26 27 |
# File 'lib/rasti/model/attribute.rb', line 25 def to_s "#{self.class}[name: #{name.inspect}, type: #{type.inspect}, options: #{.inspect}]" end |