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.
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
8 9 10 11 12 13 14 15 16 17 18 19 |
# File 'lib/ViewComposer/base_composer.rb', line 8 def initialize(model:, composable_objects: [] ) @model = model @json_hash = {} @parent_methods = self.class.superclass.instance_methods(false) @composer_methods = self.class.instance_methods(false) @dont_redefine = @parent_methods + @composer_methods @_attrs = self.class._attributes set_attributes setup_comp_objs(composable_objects) methods_to_hash end |
Class Attribute Details
._attributes ⇒ Object
Returns the value of attribute _attributes.
4 5 6 |
# File 'lib/ViewComposer/base_composer.rb', line 4 def _attributes @_attributes end |
Class Method Details
.attributes(*attrs) ⇒ Object
29 30 31 |
# File 'lib/ViewComposer/base_composer.rb', line 29 def self.attributes(*attrs) Array(attrs).each {|attr| self._attributes << attr} end |
.inherited(base) ⇒ Object
33 34 35 36 |
# File 'lib/ViewComposer/base_composer.rb', line 33 def self.inherited(base) super base._attributes = self._attributes.dup end |
Instance Method Details
#hash_attrs ⇒ Object
21 22 23 |
# File 'lib/ViewComposer/base_composer.rb', line 21 def hash_attrs @json_hash end |
#to_json ⇒ Object
25 26 27 |
# File 'lib/ViewComposer/base_composer.rb', line 25 def to_json @json_hash.to_json end |