Class: Croesus::Attribute
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
27 28 29 30 31 32 33 34 35 |
# File 'lib/croesus/attribute.rb', line 27 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.
23 24 25 |
# File 'lib/croesus/attribute.rb', line 23 def type @type end |
Instance Method Details
#default ⇒ Object
37 38 39 |
# File 'lib/croesus/attribute.rb', line 37 def default @default.call end |