ViewComposer 0.0.1 → 0.1.0

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: b9b1b9f795d51602614e1897b172815a6db31544
4
- data.tar.gz: aad55d1b583e69d55ededaf976543a8637ff50a9
3
+ metadata.gz: 336035687d6fa286eec62a0435eda547764ee858
4
+ data.tar.gz: 9e6a4ee0f9c9962fccc6109eade59ef5017870ef
5
5
  SHA512:
6
- metadata.gz: 08d7c5aeb332b990cbdeb1a455c7e1437854c7a607f8bab5d747ed481cdb1ce47a80d55648476efd4ac40d26c198b5e6aef0596686c3fc5f5b44bfcdefe4f0c4
7
- data.tar.gz: 4474d2b7cc8e6e533bfe0cc1f3cd0d5adc6c2973ee6eb3ff2ff387d9e7e0f94ed92aa2c8c4ed6bec824ff9b17b4517e5060764b3de3fa76493dd7d0ae1e3f7b5
6
+ metadata.gz: 24a3bb451d252802e4851cc673332c60ac67576a35b7857624a10347f5aa67a505c31f5f8ffd889c5e81a7ba8f626e093c7e2e7e9fcc8046bd4f2654cd00bba4
7
+ data.tar.gz: e99e8f56e587c443744063d04753dd9f536feae1f78c63ee7ee34fec1a46a98d42c2342573cfe406113e717360f31c7a0154d130cf1c6516b7f2035832ce2039
data/.rspec CHANGED
@@ -1,2 +1,2 @@
1
- --format documentation
1
+ --format progress
2
2
  --color
@@ -1,12 +1,16 @@
1
1
  require 'json'
2
2
  class BaseComposer
3
- @attributes ||= []
3
+ class << self
4
+ attr_accessor :_attributes
5
+ end
6
+ self._attributes = []
7
+
4
8
  def initialize(model:, composable_objects: [] )
5
- #self.class.attributes
6
9
  @model = model
7
- @composer_methods = self.class.instance_methods(false)
8
10
  @json_hash = {}
9
- set_attributes(self.class.get_attributes)
11
+ @composer_methods = self.class.instance_methods(false)
12
+ @_attrs = self.class._attributes
13
+ set_attributes
10
14
  setup_comp_objs(composable_objects)
11
15
  methods_to_hash
12
16
  end
@@ -19,29 +23,17 @@ class BaseComposer
19
23
  @json_hash.to_json
20
24
  end
21
25
 
22
- def self.attributes(*attributes)
23
- @attributes = attributes
24
- end
25
-
26
- def self.get_attributes
27
- @attributes || []
26
+ def self.attributes(*attrs)
27
+ Array(attrs).each {|attr| self._attributes << attr}
28
28
  end
29
29
 
30
30
  def self.inherited(base)
31
31
  super
32
- #puts "#{base}: #{get_attributes}"
32
+ base._attributes = self._attributes.dup
33
33
  end
34
34
 
35
35
  private
36
36
 
37
- def define_methods(method_names, method_owner)
38
- method_names.each do |attr|
39
- self.class.send(:define_method, attr) do
40
- method_owner.send(attr)
41
- end
42
- end
43
- end
44
-
45
37
  def methods_to_hash
46
38
  methods = self.class.instance_methods(false) - [:to_json, :hash_attrs]
47
39
  methods.each do |method|
@@ -49,8 +41,8 @@ private
49
41
  end
50
42
  end
51
43
 
52
- def set_attributes(attrs)
53
- defineable_methods = attrs - @composer_methods
44
+ def set_attributes
45
+ defineable_methods = @_attrs - @composer_methods
54
46
  define_methods(defineable_methods, @model)
55
47
  end
56
48
 
@@ -62,4 +54,12 @@ private
62
54
  end
63
55
  end
64
56
 
57
+ def define_methods(method_names, method_owner)
58
+ method_names.each do |attr|
59
+ self.class.send(:define_method, attr) do
60
+ method_owner.send(attr)
61
+ end
62
+ end
63
+ end
64
+
65
65
  end
@@ -1,3 +1,3 @@
1
1
  module ViewComposer
2
- VERSION = "0.0.1"
2
+ VERSION = "0.1.0"
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.0.1
4
+ version: 0.1.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Kory Tegman