Class: BaseComposer
- Inherits:
-
Object
- Object
- BaseComposer
- Defined in:
- lib/ViewComposer/base_composer.rb
Class Attribute Summary collapse
-
._attributes ⇒ Object
Returns the value of attribute _attributes.
-
._inherited_methods ⇒ Object
Returns the value of attribute _inherited_methods.
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.
10 11 12 13 14 15 16 17 18 19 20 |
# File 'lib/ViewComposer/base_composer.rb', line 10 def initialize(model:, composable_objects: [] ) set_inherited_methods_list @model = model @json_hash = {} @_attrs = self.class._attributes @inherited_methods = self.class._inherited_methods @instance_methods = self.class.instance_methods(false) set_attributes_methods setup_comp_objs(composable_objects) methods_to_hash end |
Class Attribute Details
._attributes ⇒ Object
Returns the value of attribute _attributes.
5 6 7 |
# File 'lib/ViewComposer/base_composer.rb', line 5 def _attributes @_attributes end |
._inherited_methods ⇒ Object
Returns the value of attribute _inherited_methods.
5 6 7 |
# File 'lib/ViewComposer/base_composer.rb', line 5 def _inherited_methods @_inherited_methods end |
Class Method Details
.attributes(*attrs) ⇒ Object
30 31 32 |
# File 'lib/ViewComposer/base_composer.rb', line 30 def self.attributes(*attrs) Array(attrs).each {|attr| self._attributes << attr} end |
.inherited(base) ⇒ Object
34 35 36 37 38 |
# File 'lib/ViewComposer/base_composer.rb', line 34 def self.inherited(base) super base._attributes = self._attributes.dup base._inherited_methods = self._inherited_methods.dup end |
Instance Method Details
#hash_attrs ⇒ Object
22 23 24 |
# File 'lib/ViewComposer/base_composer.rb', line 22 def hash_attrs @json_hash end |
#to_json ⇒ Object
26 27 28 |
# File 'lib/ViewComposer/base_composer.rb', line 26 def to_json @json_hash.to_json end |