Class: Yukata::Attribute
- Inherits:
-
Object
- Object
- Yukata::Attribute
- Defined in:
- lib/yukata/attribute.rb
Overview
A single attribute that is attached to a model
Instance Attribute Summary collapse
-
#type ⇒ Object
readonly
Returns the value of attribute type.
Instance Method Summary collapse
- #default ⇒ Object
-
#initialize(type = String, options = {}) ⇒ Attribute
constructor
A new instance of Attribute.
Constructor Details
#initialize(type = String, options = {}) ⇒ Attribute
Returns a new instance of Attribute.
10 11 12 13 14 15 16 17 18 |
# File 'lib/yukata/attribute.rb', line 10 def initialize(type=String, ={}) @type = type if [:default].is_a?(Proc) @default = [:default] else @default = -> { [:default] } end end |
Instance Attribute Details
#type ⇒ Object (readonly)
Returns the value of attribute type.
6 7 8 |
# File 'lib/yukata/attribute.rb', line 6 def type @type end |
Instance Method Details
#default ⇒ Object
20 21 22 |
# File 'lib/yukata/attribute.rb', line 20 def default @default.call end |