ViewComposer 0.1.1 → 0.1.2
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 +4 -4
- data/lib/ViewComposer/base_composer.rb +25 -12
- data/lib/ViewComposer/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: bd8b4384af9920af4a5170465c1da6ff82fa424e
|
4
|
+
data.tar.gz: 3e25d90731d18cc8e0a6d2e65e8d55e0aa83f9ad
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 28531525aacedf8b0fa5ec5cd4349b551483a7ee020c3e585f90cc698df30478c405aa7a9dc8f726359266ba07921f552285e84bf43b3a6f01d4af41b0c5ca0e
|
7
|
+
data.tar.gz: e2c7ed6bf365d9afd36870ea67d75c0ac818ae78a7adb4aee979e89364d47dc7de766b7ac4e3ea66539412cd9bd682bbbb60eef805f571ecaa04bb4c3538b026
|
@@ -1,19 +1,20 @@
|
|
1
1
|
require 'json'
|
2
|
+
EXCLUDED_METHODS = [:to_json, :hash_attrs, :set_inherited_methods_list]
|
2
3
|
class BaseComposer
|
3
4
|
class << self
|
4
|
-
attr_accessor :_attributes
|
5
|
+
attr_accessor :_attributes, :_inherited_methods
|
5
6
|
end
|
6
7
|
self._attributes = []
|
8
|
+
self._inherited_methods = []
|
7
9
|
|
8
10
|
def initialize(model:, composable_objects: [] )
|
11
|
+
set_inherited_methods_list
|
9
12
|
@model = model
|
10
13
|
@json_hash = {}
|
11
|
-
|
12
|
-
@parent_methods = self.class.superclass.instance_methods(false)
|
13
|
-
@composer_methods = self.class.instance_methods(false)
|
14
|
-
@dont_redefine = @parent_methods + @composer_methods
|
15
14
|
@_attrs = self.class._attributes
|
16
|
-
|
15
|
+
@inherited_methods = self.class._inherited_methods
|
16
|
+
@instance_methods = self.class.instance_methods(false)
|
17
|
+
set_attributes_methods
|
17
18
|
setup_comp_objs(composable_objects)
|
18
19
|
methods_to_hash
|
19
20
|
end
|
@@ -33,21 +34,34 @@ class BaseComposer
|
|
33
34
|
def self.inherited(base)
|
34
35
|
super
|
35
36
|
base._attributes = self._attributes.dup
|
37
|
+
base._inherited_methods = self._inherited_methods.dup
|
36
38
|
end
|
37
39
|
|
38
40
|
private
|
39
41
|
|
42
|
+
def get_all_methods
|
43
|
+
(@_attrs + @inherited_methods + @instance_methods).uniq
|
44
|
+
end
|
45
|
+
|
46
|
+
def set_inherited_methods_list
|
47
|
+
_methods = self.class.superclass.instance_methods(false) - EXCLUDED_METHODS
|
48
|
+
self.class._inherited_methods += _methods
|
49
|
+
end
|
50
|
+
|
40
51
|
def methods_to_hash
|
41
|
-
methods =
|
52
|
+
methods = get_all_methods - EXCLUDED_METHODS
|
42
53
|
methods.each do |method|
|
43
54
|
@json_hash[method] = self.send(method)
|
44
55
|
end
|
45
56
|
end
|
46
57
|
|
47
|
-
def
|
48
|
-
|
49
|
-
|
50
|
-
|
58
|
+
def set_attributes_methods
|
59
|
+
define_methods(definable_methods, @model)
|
60
|
+
end
|
61
|
+
|
62
|
+
def definable_methods
|
63
|
+
m = @_attrs - @inherited_methods
|
64
|
+
m - @instance_methods
|
51
65
|
end
|
52
66
|
|
53
67
|
def setup_comp_objs(comp_objs_array)
|
@@ -61,7 +75,6 @@ private
|
|
61
75
|
def define_methods(method_names, method_owner)
|
62
76
|
method_names.each do |attr|
|
63
77
|
self.class.send(:define_method, attr) do
|
64
|
-
#puts method_owner.send(attr)
|
65
78
|
method_owner.send(attr)
|
66
79
|
end
|
67
80
|
end
|
data/lib/ViewComposer/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: ViewComposer
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Kory Tegman
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2016-08-
|
11
|
+
date: 2016-08-08 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|