materialize 0.4.0 → 0.4.1

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: 63cce4807d7438dcd0c3a4ea2d1a86db888e73f0
4
- data.tar.gz: 1432d5e143568622616c933951c08452371b5d7b
3
+ metadata.gz: 62835d5edc997985eb7a005a787c66ccf9a0ab4a
4
+ data.tar.gz: 4c964cbb78c9e88a564c9697e0759093323bf600
5
5
  SHA512:
6
- metadata.gz: 7496b0a4ac9caa95f074f2e5e031e8c97ae4a83a7144e6895aa1850203ee6234bc0ed5336af9da493db7c12773b59c37aadbac32fd308acb49e9aee9a79284a1
7
- data.tar.gz: 1fae6166f03bd065f7f1137825f58bc155db5081f834acc6ae6eddebd491cb9629b3edfbee299947ae9fe1c18dc0862a0bede6951262cdb3e930d550db06c841
6
+ metadata.gz: 383b43dd28af0bb63f626a5a8596c6f43ace9d32d3687192a8e77e3c60472e997f44bd6ce1d7f5f9dc50bca3f511c28a34a595dad4f103201965b881d83799c2
7
+ data.tar.gz: 7ee96bc1c83b54b31f92a5d295bf668262fe6463c7ed73ae5dea9847f1717087b0fccb878c67197967819dc5b8ce49eb4924244d2da1fccf66492e1d8373b92a
@@ -13,27 +13,43 @@ module Materialize
13
13
  options = args[1] || {}
14
14
  args_to_pass = options[:args]
15
15
 
16
- data, builder_class = process(data_source_class, query, args_to_pass)
16
+ data, builder_class, entity_class = process(data_source_class, query, args_to_pass)
17
17
 
18
18
  yield(data) if block_given?
19
19
 
20
20
  options.delete(:args)
21
21
 
22
- if data.is_a?(Hash) and !data['message'].nil?
23
- Response.new data
24
- elsif data.is_a?(Array)
25
- builder_class.build_all(data, self, options)
22
+ # TODO: add a temporary bypass switch that skips builders
23
+ # TODO: Switch to something like data['m_message'] to avoid collisions
24
+
25
+ if options[:skip_builders]
26
+ if data.is_a?(Hash) and !data['message'].nil?
27
+ Response.new data
28
+ elsif data.is_a?(Array)
29
+ builder_class.build_all(data, self, options)
30
+ else
31
+ builder_class.build(data, self, options)
32
+ end
26
33
  else
27
- builder_class.build(data, self, options)
34
+ if data.is_a?(Hash) and !data['message'].nil?
35
+ Response.new data
36
+ elsif data.is_a?(Array)
37
+ builder_class.build_all(data, self, options)
38
+ else
39
+ builder_class.build(data, self, options)
40
+ end
28
41
  end
42
+
29
43
  end
30
44
 
31
45
  private
32
46
 
33
47
  def process(data_source_class, query, args_to_pass)
34
- data = get_data(data_source_class, query, args_to_pass)
48
+ data = get_data(data_source_class, query, args_to_pass)
35
49
  builder_class = builder_class_for builder_class_name_for base_class_name_for data_source_class
36
- return data, builder_class
50
+ entity_class = entity_class_for base_class_name_for data_source_class
51
+
52
+ return data, builder_class, entity_class
37
53
  end
38
54
 
39
55
  def builder_class_for(builder_class_name)
@@ -48,6 +64,10 @@ module Materialize
48
64
  "#{base_class_name}Builder"
49
65
  end
50
66
 
67
+ def entity_class_for(base_class_name)
68
+ Module.const_get("Entities::#{base_class_name}")
69
+ end
70
+
51
71
  def base_class_name_for(data_source_class)
52
72
  data_source_class.name.split('::').last
53
73
  end
@@ -1,3 +1,3 @@
1
1
  module Materialize
2
- VERSION = "0.4.0"
2
+ VERSION = "0.4.1"
3
3
  end
Binary file
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: materialize
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.4.0
4
+ version: 0.4.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Stephen Fiser
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2017-02-16 00:00:00.000000000 Z
11
+ date: 2017-02-28 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activesupport
@@ -107,6 +107,7 @@ files:
107
107
  - lib/materialize/utils.rb
108
108
  - lib/materialize/version.rb
109
109
  - materialize-0.3.5.gem
110
+ - materialize-0.4.0.gem
110
111
  - materialize.gemspec
111
112
  homepage: http://bluebear.io
112
113
  licenses:
@@ -129,7 +130,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
129
130
  version: '0'
130
131
  requirements: []
131
132
  rubyforge_project:
132
- rubygems_version: 2.6.8
133
+ rubygems_version: 2.6.10
133
134
  signing_key:
134
135
  specification_version: 4
135
136
  summary: This is the summary.