Class: Decoradar::Attribute
- Inherits:
-
Object
- Object
- Decoradar::Attribute
- Defined in:
- lib/decoradar/attribute.rb
Direct Known Subclasses
Instance Attribute Summary collapse
-
#as ⇒ Object
readonly
Returns the value of attribute as.
-
#include_if ⇒ Object
readonly
Returns the value of attribute include_if.
-
#name ⇒ Object
readonly
Returns the value of attribute name.
Instance Method Summary collapse
- #including?(object) ⇒ Boolean
-
#initialize(options = {}) ⇒ Attribute
constructor
A new instance of Attribute.
- #serialize(hash, value) ⇒ Object
Constructor Details
#initialize(options = {}) ⇒ Attribute
Returns a new instance of Attribute.
5 6 7 8 9 |
# File 'lib/decoradar/attribute.rb', line 5 def initialize( = {}) @name = .fetch(:name) @as = .fetch(:as, @name) @include_if = [:include_if] end |
Instance Attribute Details
#as ⇒ Object (readonly)
Returns the value of attribute as.
3 4 5 |
# File 'lib/decoradar/attribute.rb', line 3 def as @as end |
#include_if ⇒ Object (readonly)
Returns the value of attribute include_if.
3 4 5 |
# File 'lib/decoradar/attribute.rb', line 3 def include_if @include_if end |
#name ⇒ Object (readonly)
Returns the value of attribute name.
3 4 5 |
# File 'lib/decoradar/attribute.rb', line 3 def name @name end |
Instance Method Details
#including?(object) ⇒ Boolean
11 12 13 14 15 16 17 |
# File 'lib/decoradar/attribute.rb', line 11 def including?(object) case include_if when nil then true when Proc then include_if.call(object) else false end end |
#serialize(hash, value) ⇒ Object
19 20 21 |
# File 'lib/decoradar/attribute.rb', line 19 def serialize(hash, value) hash.merge(as => value) end |