Class: Setsy::Attribute
- Inherits:
-
Object
- Object
- Setsy::Attribute
- Defined in:
- lib/setsy/attribute.rb
Constant Summary collapse
- KLASS_MAP =
{ 'true' => 'Boolean', 'false' => 'Boolean', 'trueclass' => 'Boolean', 'falseclass' => 'Boolean', 'fixnum' => 'Integer' }.freeze
Instance Method Summary collapse
- #default ⇒ Object
- #default? ⇒ Boolean
-
#initialize(options) ⇒ Attribute
constructor
A new instance of Attribute.
- #to_s ⇒ Object
- #value ⇒ Object (also: #as_json)
Constructor Details
#initialize(options) ⇒ Attribute
Returns a new instance of Attribute.
12 13 14 15 16 |
# File 'lib/setsy/attribute.rb', line 12 def initialize() @attribute_value = [:value] @default = [:default] @options = end |
Instance Method Details
#default ⇒ Object
27 28 29 |
# File 'lib/setsy/attribute.rb', line 27 def default @default ||= cast(@default) end |
#default? ⇒ Boolean
31 32 33 |
# File 'lib/setsy/attribute.rb', line 31 def default? value == default end |
#to_s ⇒ Object
18 19 20 |
# File 'lib/setsy/attribute.rb', line 18 def to_s @to_s ||= cast(@attribute_value).to_s end |
#value ⇒ Object Also known as: as_json
22 23 24 |
# File 'lib/setsy/attribute.rb', line 22 def value @value ||= cast(@attribute_value) end |