tarvit-helpers 0.0.18 → 0.0.19
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/VERSION +1 -1
- data/lib/tarvit-helpers/modules/hash_presenter/cached_hash_presenter.rb +1 -1
- data/lib/tarvit-helpers/modules/hash_presenter/observable_hash_presenter.rb +1 -1
- data/lib/tarvit-helpers/modules/hash_presenter/simple_hash_presenter.rb +4 -3
- data/lib/tarvit-helpers/modules/hash_presenter/with_rules_hash_presenter.rb +3 -3
- data/spec/modules/hash_presenter_spec.rb +7 -2
- data/tarvit-helpers.gemspec +2 -2
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 05681b4357edadeefed8c63c26fa6d22f503858e
|
4
|
+
data.tar.gz: 0820720e92d9e22990d0cd423e735d6a3509f58e
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: d1198afc24a8e13956e76e4237cefe9e625428b0e532de709d44260879886c1d19b5c13d70f1ef2433d3939ca31c99718597bd00f33375c4910cbf34238a3134
|
7
|
+
data.tar.gz: 31ba51b3bac58da767fc61d58be22341a0be84469a1e5d723c6ed7fe42fbc6750eec1e8d77d8ff746e3a33ed9f3eccc4abd23c650675470afd035eca74ca905f
|
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.0.
|
1
|
+
0.0.19
|
@@ -4,11 +4,12 @@ module TarvitHelpers
|
|
4
4
|
class Simple
|
5
5
|
require 'active_support/core_ext/string'
|
6
6
|
|
7
|
-
attr_reader :_hash, :_levels
|
7
|
+
attr_reader :_hash, :_levels, :_parent
|
8
8
|
|
9
|
-
def initialize(hash, levels=[])
|
9
|
+
def initialize(hash, levels=[], parent=nil)
|
10
10
|
@_hash = _prepare_keys(hash)
|
11
11
|
@_levels = levels
|
12
|
+
@_parent = parent
|
12
13
|
end
|
13
14
|
|
14
15
|
def method_missing(m, *args)
|
@@ -51,7 +52,7 @@ module TarvitHelpers
|
|
51
52
|
end
|
52
53
|
|
53
54
|
def _new_level_presenter(value, method_name)
|
54
|
-
self.class.new(value, _path(method_name))
|
55
|
+
self.class.new(value, _path(method_name), self)
|
55
56
|
end
|
56
57
|
|
57
58
|
end
|
@@ -4,8 +4,8 @@ module TarvitHelpers
|
|
4
4
|
class WithRules < Cached
|
5
5
|
attr_reader :_rules_holder
|
6
6
|
|
7
|
-
def initialize(hash, levels=[], rules_holder=nil, &rules)
|
8
|
-
super(hash, levels)
|
7
|
+
def initialize(hash, levels=[], parent=nil, rules_holder=nil, &rules)
|
8
|
+
super(hash, levels, parent)
|
9
9
|
@_rules_holder = rules_holder || RulesHolder.new
|
10
10
|
_init_rules if _rules_holder.rules.empty?
|
11
11
|
rules.call(_rules_holder) if rules
|
@@ -24,7 +24,7 @@ module TarvitHelpers
|
|
24
24
|
end
|
25
25
|
|
26
26
|
def _new_level_presenter(value, method_name)
|
27
|
-
self.class.new(value, _path(method_name), _rules_holder)
|
27
|
+
self.class.new(value, _path(method_name), self, _rules_holder)
|
28
28
|
end
|
29
29
|
|
30
30
|
def _init_rules; end
|
@@ -212,6 +212,10 @@ describe HashPresenter::Custom do
|
|
212
212
|
rules.when([:accounts, :collections, :folder]) do |value, object|
|
213
213
|
"folders/#{object.name}"
|
214
214
|
end
|
215
|
+
|
216
|
+
rules.when([:accounts, :collections, :global_folder]) do |value, object|
|
217
|
+
"#{object._parent.name}/folders/#{object.name}"
|
218
|
+
end
|
215
219
|
end
|
216
220
|
end
|
217
221
|
|
@@ -227,6 +231,7 @@ describe HashPresenter::Custom do
|
|
227
231
|
expect(account.collections[0].folder).to eq('folders/TestCollection')
|
228
232
|
expect(account.collections[1].name).to eq('BestCollection')
|
229
233
|
expect(account.collections[1].folder).to eq('folders/BestCollection')
|
234
|
+
expect(account.collections[1].global_folder).to eq('director/folders/BestCollection')
|
230
235
|
|
231
236
|
expect(@presenter._custom_hash).to eq({
|
232
237
|
:accounts => [
|
@@ -234,8 +239,8 @@ describe HashPresenter::Custom do
|
|
234
239
|
:id=>1,
|
235
240
|
:name=>'director',
|
236
241
|
:collections=>[
|
237
|
-
{:id=>42, :name=>'TestCollection', :folder=>'folders/TestCollection'},
|
238
|
-
{:id=>24, :name=>'BestCollection', :folder=>'folders/BestCollection'},
|
242
|
+
{:id=>42, :name=>'TestCollection', :folder=>'folders/TestCollection', :global_folder=>'director/folders/TestCollection'},
|
243
|
+
{:id=>24, :name=>'BestCollection', :folder=>'folders/BestCollection', :global_folder=>'director/folders/BestCollection'},
|
239
244
|
],
|
240
245
|
:website=>'www.johndoe.com/director'
|
241
246
|
}
|
data/tarvit-helpers.gemspec
CHANGED
@@ -2,11 +2,11 @@
|
|
2
2
|
# DO NOT EDIT THIS FILE DIRECTLY
|
3
3
|
# Instead, edit Jeweler::Tasks in Rakefile, and run 'rake gemspec'
|
4
4
|
# -*- encoding: utf-8 -*-
|
5
|
-
# stub: tarvit-helpers 0.0.
|
5
|
+
# stub: tarvit-helpers 0.0.19 ruby lib
|
6
6
|
|
7
7
|
Gem::Specification.new do |s|
|
8
8
|
s.name = "tarvit-helpers"
|
9
|
-
s.version = "0.0.
|
9
|
+
s.version = "0.0.19"
|
10
10
|
|
11
11
|
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
12
12
|
s.require_paths = ["lib"]
|