Class: BaseComposer

Inherits:
Object
  • Object
show all
Defined in:
lib/ViewComposer/base_composer.rb

Class Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

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

._attributesObject

Returns the value of attribute _attributes.



5
6
7
# File 'lib/ViewComposer/base_composer.rb', line 5

def _attributes
  @_attributes
end

._inherited_methodsObject

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_attrsObject



22
23
24
# File 'lib/ViewComposer/base_composer.rb', line 22

def hash_attrs
  @json_hash
end

#to_jsonObject



26
27
28
# File 'lib/ViewComposer/base_composer.rb', line 26

def to_json
  @json_hash.to_json
end