brace_comb 0.1.1 → 0.1.2

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: 1bfd2a6dfe32328fd413215449ec8880f0a50cba
4
- data.tar.gz: d3d8f3995d6695d34cfec43ac0e1fbfd2109d65c
3
+ metadata.gz: c3f4a2060ab1b9507b4ec5ea18df91473e465ba3
4
+ data.tar.gz: 86ab140e66bc4d9432ca8f02b9a7690715b620b1
5
5
  SHA512:
6
- metadata.gz: 8f4d959428312946a06ec5fc78da49a1b30b9ec9d3e08de0bf81c481e310caf64cec80db870dab19a4c1f1732cc1a761576d0e163107603f91991890764a0074
7
- data.tar.gz: ce0b8b59c727609cafe7244d29e6e7020af6cbdda06a258767651f9dc5c1ba571381c23ddacc85ff5be2dc27c2de71682484e3877148b46edbf06fd73d0cf353
6
+ metadata.gz: 96a050f07a60bfd8c59466a56c0ee6147c8c2e72c190399f4d9b9305f0fdfbfc81c4c0fbcf85e3880c618b55437887295fe60d930c240845196f15ba91ad46ca
7
+ data.tar.gz: e65946dbf7044edaf1722e2ccb5fe93834b566500cb1462e03b587c1bc14652fb27acefa2607329df1c8727a0142cef2de831c108e74a491448bd0d8f456dc8b
data/README.md CHANGED
@@ -61,7 +61,7 @@ Entity names for dependencies and dependents are configurable and can be set in
61
61
  include BraceComb::Helper
62
62
  enum type: { shopping: 0 }
63
63
  ```
64
- 2. Declare a dependency by typing in the following in any ActiveRecord class:
64
+ 2. Declare a dependency by typing in the following in any ActiveRecord class. Only `resolver` is compulsory whereas `before_resolution` and `after_resolution` are optional.
65
65
 
66
66
  a. Using a method name in the resolver
67
67
  ```
@@ -27,6 +27,7 @@ module BraceComb
27
27
  end
28
28
 
29
29
  def execute_after_callbacks(after_callbacks)
30
+ return unless after_callbacks
30
31
  after_callbacks.each do |after_callback|
31
32
  execute_callback(after_callback)
32
33
  end
@@ -43,6 +44,7 @@ module BraceComb
43
44
  end
44
45
 
45
46
  def execute_before_callbacks(before_callbacks)
47
+ return unless before_callbacks
46
48
  before_callbacks.each do |before_callback|
47
49
  result = execute_callback(before_callback)
48
50
  raise BraceComb::Exceptions::CallbackFailure.new unless result
@@ -1,3 +1,3 @@
1
1
  module BraceComb
2
- VERSION = '0.1.1'
2
+ VERSION = '0.1.2'
3
3
  end
@@ -7,8 +7,8 @@ module BraceComb
7
7
  create_file(
8
8
  'config/initializers/brace_comb.rb',
9
9
  "BraceComb.setup do |config|\n"\
10
- " config.dependent_table_name = '#{dependent_table_name}'\n"\
11
- " config.dependency_table_name = '#{dependency_table_name}'\n"\
10
+ " config.dependent_table_name = '#{dependent_table_name}'\n"\
11
+ " config.dependency_table_name = '#{dependency_table_name}'\n"\
12
12
  "end"
13
13
  )
14
14
  end
@@ -128,6 +128,21 @@ describe BraceComb::Model do
128
128
  expect(result).to be true
129
129
  end
130
130
  end
131
+
132
+ context 'resolve without callbacks' do
133
+ before do
134
+ dependency_class.constantize.class_eval do
135
+ declare_dependency type: :shopping,
136
+ resolver: ->(data) { data.resolved! }
137
+ end
138
+ end
139
+
140
+ it 'resolves dependency if all before resolve hooks are satisfied' do
141
+ result = dependency.resolve
142
+ expect(dependency).to be_resolved
143
+ expect(result).to be true
144
+ end
145
+ end
131
146
  end
132
147
 
133
148
  context 'resolve' do
@@ -15,8 +15,8 @@ describe BraceComb::InitializerGenerator, type: :generator do
15
15
 
16
16
  it 'creates brace comb initializer' do
17
17
  assert_file 'config/initializers/brace_comb.rb', "BraceComb.setup do |config|\n"\
18
- " config.dependent_table_name = 'jobs'\n"\
19
- " config.dependency_table_name = 'job_dependencies'\n"\
18
+ " config.dependent_table_name = 'jobs'\n"\
19
+ " config.dependency_table_name = 'job_dependencies'\n"\
20
20
  "end"
21
21
  end
22
22
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: brace_comb
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.1
4
+ version: 0.1.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ankita Gupta
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2017-08-21 00:00:00.000000000 Z
11
+ date: 2017-08-22 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activerecord