ViewComposer 0.1.3 → 0.1.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: e5ce5c93cbd8b88877f158582da991558951ed51
4
- data.tar.gz: 9381c479f662719b877733ab8fd44dd185b6c3c1
3
+ metadata.gz: f0f39caa21c19edfda37bcb55bdaf219fb716e0b
4
+ data.tar.gz: 4d79b5ae56239d868d2f45bd8943bc8ad1d9b234
5
5
  SHA512:
6
- metadata.gz: ade15dc7ef22e932464c2ef42f8d7111147b9053b464097cacd0df52083753684d07fb30648315d6706b3e6d43c6bd0782ca5dc60165b051df5432f7b80ca00e
7
- data.tar.gz: a8283efa6c1a59c14f6400143b191d493aea8d53f0ccc4d64eb153260af45c83e2ffaaad848c9987a43b2e0e4a5f7aa081cffd84c3a363bce0060c743f7c0175
6
+ metadata.gz: d27ed05f84c5f0a3d1e2848881e3907d8045b8608992c4473f76b3645f8b4271c2dbc10a0cc5a2d248bcf55d0d741e1136136fd36769de05929fa88fc07a20ae
7
+ data.tar.gz: 01e11b6713eee33503ee06d4dba9043cbc0c7ebd2299f2592a967add0c3c0c2e74540d5e33766459d73312ff4f3b768287738fa9cc7cc1a70bcae4ab56a46169
@@ -12,6 +12,7 @@ class BaseComposer
12
12
  attr_accessor :_attributes,
13
13
  :_instance_attrs,
14
14
  :_model_methods,
15
+ :_instance_defined_methods,
15
16
  :_inherited_methods
16
17
  end
17
18
  self._attributes = []
@@ -24,6 +25,7 @@ class BaseComposer
24
25
  @model = model
25
26
  @json_hash = {}
26
27
  set_model_methods
28
+ set_instance_defined_methods
27
29
  set_attributes_methods
28
30
  setup_comp_objs(composable_objects)
29
31
  methods_to_hash
@@ -38,6 +40,7 @@ class BaseComposer
38
40
  super
39
41
  base._attributes = self._attributes.dup
40
42
  base._inherited_methods = self._inherited_methods.dup
43
+ base._model_methods = self._model_methods.dup
41
44
  end
42
45
 
43
46
  def hash_attrs
@@ -62,6 +65,14 @@ private
62
65
  end
63
66
  end
64
67
 
68
+ def set_instance_defined_methods
69
+ if self.class._instance_defined_methods != nil
70
+ self.class._instance_defined_methods += self.class._model_methods
71
+ else
72
+ self.class._instance_defined_methods = self.class._model_methods
73
+ end
74
+ end
75
+
65
76
  def instance_attributes
66
77
  @instance_attributes ||= self.class._instance_attrs || []
67
78
  end
@@ -104,7 +115,7 @@ private
104
115
  end
105
116
 
106
117
  def definable_methods
107
- self.class._model_methods
118
+ self.class._instance_defined_methods + self.class._model_methods
108
119
  end
109
120
 
110
121
  def setup_comp_objs(comp_objs_array)
@@ -116,7 +127,7 @@ private
116
127
  end
117
128
 
118
129
  def define_methods(method_names, method_owner)
119
- method_names.each do |attr|
130
+ method_names.uniq.each do |attr|
120
131
  self.class.send(:define_method, attr) do
121
132
  method_owner.send(attr)
122
133
  end
@@ -1,3 +1,3 @@
1
1
  module ViewComposer
2
- VERSION = "0.1.3"
2
+ VERSION = "0.1.4"
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: ViewComposer
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.3
4
+ version: 0.1.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - Kory Tegman