Class: AbcJsonapi::VirtualAttribute
- Inherits:
-
Object
- Object
- AbcJsonapi::VirtualAttribute
- Defined in:
- lib/abc_jsonapi/virtual_attribute.rb
Instance Attribute Summary collapse
-
#block ⇒ Object
readonly
Returns the value of attribute block.
-
#model ⇒ Object
readonly
Returns the value of attribute model.
-
#name ⇒ Object
readonly
Returns the value of attribute name.
Instance Method Summary collapse
-
#initialize(model:, name:, block:) ⇒ VirtualAttribute
constructor
A new instance of VirtualAttribute.
- #serializable_hash ⇒ Object
Constructor Details
#initialize(model:, name:, block:) ⇒ VirtualAttribute
Returns a new instance of VirtualAttribute.
5 6 7 8 9 |
# File 'lib/abc_jsonapi/virtual_attribute.rb', line 5 def initialize(model:, name:, block:) @model = model @name = name @block = block end |
Instance Attribute Details
#block ⇒ Object (readonly)
Returns the value of attribute block.
3 4 5 |
# File 'lib/abc_jsonapi/virtual_attribute.rb', line 3 def block @block end |
#model ⇒ Object (readonly)
Returns the value of attribute model.
3 4 5 |
# File 'lib/abc_jsonapi/virtual_attribute.rb', line 3 def model @model end |
#name ⇒ Object (readonly)
Returns the value of attribute name.
3 4 5 |
# File 'lib/abc_jsonapi/virtual_attribute.rb', line 3 def name @name end |
Instance Method Details
#serializable_hash ⇒ Object
11 12 13 |
# File 'lib/abc_jsonapi/virtual_attribute.rb', line 11 def serializable_hash { name.to_sym => block.call(model) } end |