materialist 0.0.6 → 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 3c6ac14f9290917ab258407ab5a9107b7c6d5dfd
4
- data.tar.gz: 933bb41d482b11ada3dfa436a8f2ba884d729d38
3
+ metadata.gz: ddfdebe864838d6fdb912aee5d3002417aca969b
4
+ data.tar.gz: 13ebd4c0bad48a307820aaa28c81d674335da88c
5
5
  SHA512:
6
- metadata.gz: 8348c3f30fb8202e7d714dab4ff995c3090f5a1cd401beebea3804d100ef917bc577aa9ec7d2c3be78181befb030e3c8b48f4fb6f71f622b1a8f1ba8f61b5787
7
- data.tar.gz: 526c7ba494e18b1df3a1a19dbf47965f3960e622250dd64001ce4f72ca6abdc5e6414df49fb52ff948018774f69062a344fec4b886df20f565663a45e788bd78
6
+ metadata.gz: c082a2dfffdae443aaafb41d20f4a12da3203a90bbae0e4bd8075f77364fdc67d2386de3373572d1a0b6b46bbb93d0e7a1adca2df59777f15de7c9eb9fbf0d02
7
+ data.tar.gz: 80d88005986ec167b4d599085e9fcd424c37b4cab98baacc44a38deed1731e035c8acc8da118e0be286b17f5c2de1adf95ddd4a45253b43ba9648169b4f79113
data/README.md CHANGED
@@ -116,31 +116,33 @@ require 'materialist/materializer'
116
116
  class ZoneMaterializer
117
117
  include Materialist::Materializer
118
118
 
119
- use_model :zone
119
+ persist_to :zone
120
120
 
121
- materialize :id, as: :orderweb_id
122
- materialize :code
123
- materialize :name
121
+ capture :id, as: :orderweb_id
122
+ capture :code
123
+ capture :name
124
124
 
125
125
  link :city do
126
- materialize :tz_name, as: :timezone
126
+ capture :tz_name, as: :timezone
127
127
 
128
128
  link :country do
129
- materialize :name, as: :country_name
130
- materialize :iso_alpha2_code, as: :country_iso_alpha2_code
129
+ capture :name, as: :country_name
130
+ capture :iso_alpha2_code, as: :country_iso_alpha2_code
131
131
  end
132
132
  end
133
+
134
+ materialize_link :settings, topic: :zone_settings
133
135
  end
134
136
  ```
135
137
 
136
138
  Here is what each part of the DSL mean:
137
139
 
138
- #### `use_model <model_name>`
139
- describes the name of the active record model to be used.
140
+ #### `persist_to <model_name>`
141
+ describes the name of the active record model to be used.
140
142
  If missing, materialist skips materialising the resource itself, but will continue
141
143
  with any other functionality -- such as `materialize_link`.
142
144
 
143
- #### `materialize <key>, as: <column> (default: key)`
145
+ #### `capture <key>, as: <column> (default: key)`
144
146
  describes mapping a resource key to database column.
145
147
 
146
148
  #### `link <key>`
@@ -150,8 +152,8 @@ When inside the block of a `link` any other part of DSL can be used and will be
150
152
 
151
153
  ### `materialize_link <key>, topic: <topic> (default: key)`
152
154
  describes materializing the linked entity.
153
- This simulates a `:noop` event on the given topic and the `url` if the
154
- liked resource `<key>` as it appears on the response (`_links`)
155
+ This simulates a `:noop` event on the given topic and the `url` of the
156
+ liked resource `<key>` as it appears on the response (`_links`) -- meaning the materializer for the given topic will be invoked.
155
157
 
156
158
  #### `after_upsert <method>` -- also `after_destroy`
157
159
  describes the name of the instance method to be invoked after a record was materialized.
@@ -51,7 +51,7 @@ module Materialist
51
51
  __materialist_options[:links_to_materialize][key] = { topic: topic }
52
52
  end
53
53
 
54
- def materialize(key, as: key)
54
+ def capture(key, as: key)
55
55
  __materialist_dsl_mapping_stack.last << FieldMapping.new(key: key, as: as)
56
56
  end
57
57
 
@@ -63,7 +63,7 @@ module Materialist
63
63
  __materialist_dsl_mapping_stack.pop
64
64
  end
65
65
 
66
- def use_model(klass)
66
+ def persist_to(klass)
67
67
  __materialist_options[:model_class] = klass
68
68
  end
69
69
 
data/lib/materialist.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  module Materialist
2
- VERSION = '0.0.6'
2
+ VERSION = '0.1.0'
3
3
  end
data/materialist.gemspec CHANGED
@@ -16,7 +16,7 @@ Gem::Specification.new do |spec|
16
16
  spec.test_files = spec.files.grep(%r{^spec/})
17
17
  spec.require_paths = %w(lib)
18
18
 
19
- spec.add_runtime_dependency 'sidekiq'
19
+ spec.add_runtime_dependency 'sidekiq', '>= 5.0'
20
20
  spec.add_runtime_dependency 'activesupport'
21
21
  spec.add_runtime_dependency 'routemaster-drain', '>= 3.0'
22
22
 
@@ -10,17 +10,17 @@ RSpec.describe Materialist::Materializer do
10
10
  class FoobarMaterializer
11
11
  include Materialist::Materializer
12
12
 
13
- use_model :foobar
14
- materialize :name
15
- materialize :age, as: :how_old
13
+ persist_to :foobar
14
+ capture :name
15
+ capture :age, as: :how_old
16
16
 
17
17
  materialize_link :city
18
18
 
19
19
  link :city do
20
- materialize :timezone
20
+ capture :timezone
21
21
 
22
22
  link :country do
23
- materialize :tld, as: :country_tld
23
+ capture :tld, as: :country_tld
24
24
  end
25
25
  end
26
26
  end
@@ -28,8 +28,8 @@ RSpec.describe Materialist::Materializer do
28
28
  class CityMaterializer
29
29
  include Materialist::Materializer
30
30
 
31
- use_model :city
32
- materialize :name
31
+ persist_to :city
32
+ capture :name
33
33
  end
34
34
  end
35
35
 
@@ -240,7 +240,7 @@ RSpec.describe Materialist::Materializer do
240
240
  class FoobarMaterializer
241
241
  include Materialist::Materializer
242
242
 
243
- use_model :foobar
243
+ persist_to :foobar
244
244
  after_upsert :my_method
245
245
 
246
246
  def my_method(entity)
@@ -274,7 +274,7 @@ RSpec.describe Materialist::Materializer do
274
274
  class FoobarMaterializer
275
275
  include Materialist::Materializer
276
276
 
277
- use_model :foobar
277
+ persist_to :foobar
278
278
  after_destroy :my_method
279
279
 
280
280
  def my_method(entity)
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: materialist
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.6
4
+ version: 0.1.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Mo Valipour
@@ -16,14 +16,14 @@ dependencies:
16
16
  requirements:
17
17
  - - ">="
18
18
  - !ruby/object:Gem::Version
19
- version: '0'
19
+ version: '5.0'
20
20
  type: :runtime
21
21
  prerelease: false
22
22
  version_requirements: !ruby/object:Gem::Requirement
23
23
  requirements:
24
24
  - - ">="
25
25
  - !ruby/object:Gem::Version
26
- version: '0'
26
+ version: '5.0'
27
27
  - !ruby/object:Gem::Dependency
28
28
  name: activesupport
29
29
  requirement: !ruby/object:Gem::Requirement