Class: ViewComposer::BaseComposer
- Inherits:
-
Object
- Object
- ViewComposer::BaseComposer
- Defined in:
- lib/view_composer/base_composer.rb
Class Attribute Summary collapse
-
._attributes ⇒ Object
Returns the value of attribute _attributes.
Class Method Summary collapse
Instance Method Summary collapse
- #hash_attrs ⇒ Object
-
#initialize(model:, composable_objects: []) ⇒ BaseComposer
constructor
A new instance of BaseComposer.
- #to_json ⇒ Object
Constructor Details
#initialize(model:, composable_objects: []) ⇒ BaseComposer
Returns a new instance of BaseComposer.
12 13 14 15 16 17 18 19 20 |
# File 'lib/view_composer/base_composer.rb', line 12 def initialize(model:, composable_objects: [] ) @model = model @json_hash = {} set_model_methods set_attributes_methods setup_comp_objs(composable_objects) methods_to_hash end |
Class Attribute Details
._attributes ⇒ Object
Returns the value of attribute _attributes.
8 9 10 |
# File 'lib/view_composer/base_composer.rb', line 8 def _attributes @_attributes end |
Class Method Details
.attributes(*attrs) ⇒ Object
22 23 24 |
# File 'lib/view_composer/base_composer.rb', line 22 def self.attributes(*attrs) Array(attrs).each {|attr| self._attributes << attr} end |
.inherited(base) ⇒ Object
26 27 28 29 |
# File 'lib/view_composer/base_composer.rb', line 26 def self.inherited(base) super base._attributes = self._attributes.dup end |
Instance Method Details
#hash_attrs ⇒ Object
31 32 33 |
# File 'lib/view_composer/base_composer.rb', line 31 def hash_attrs @json_hash end |
#to_json ⇒ Object
35 36 37 |
# File 'lib/view_composer/base_composer.rb', line 35 def to_json @json_hash.to_json end |