Class: Transmutable::Base
- Inherits:
-
Object
- Object
- Transmutable::Base
- Defined in:
- lib/transmutable/base.rb
Instance Attribute Summary collapse
-
#model ⇒ Object
Returns the value of attribute model.
Class Method Summary collapse
- .add_to_transmute(*methods) ⇒ Object
- .remove_from_transmute(*methods) ⇒ Object
- .serialize_attrs(*methods) ⇒ Object
Instance Method Summary collapse
-
#initialize(model) ⇒ Base
constructor
A new instance of Base.
- #transmute ⇒ Object
Constructor Details
#initialize(model) ⇒ Base
Returns a new instance of Base.
23 24 25 |
# File 'lib/transmutable/base.rb', line 23 def initialize(model) @model = model end |
Instance Attribute Details
#model ⇒ Object
Returns the value of attribute model.
3 4 5 |
# File 'lib/transmutable/base.rb', line 3 def model @model end |
Class Method Details
.add_to_transmute(*methods) ⇒ Object
5 6 7 8 9 |
# File 'lib/transmutable/base.rb', line 5 def self.add_to_transmute(*methods) define_method :transmute_addons do methods end end |
.remove_from_transmute(*methods) ⇒ Object
11 12 13 14 15 |
# File 'lib/transmutable/base.rb', line 11 def self.remove_from_transmute(*methods) define_method :transmute_skips do methods end end |
.serialize_attrs(*methods) ⇒ Object
17 18 19 20 21 |
# File 'lib/transmutable/base.rb', line 17 def self.serialize_attrs(*methods) define_method :default_attrs do methods end end |
Instance Method Details
#transmute ⇒ Object
27 28 29 |
# File 'lib/transmutable/base.rb', line 27 def transmute Hash[serialize_methods.map { |attribute| [attribute, model.send(attribute)] }] end |