customize 0.0.2 → 0.0.3
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.
- data/VERSION +1 -1
- data/customize.gemspec +1 -1
- data/lib/customize/characterize.rb +1 -0
- data/lib/customize/inherited.rb +3 -0
- data/spec/customize/characterize_spec.rb +50 -36
- data/spec/customize/inherited_spec.rb +4 -0
- metadata +2 -2
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.0.
|
1
|
+
0.0.3
|
data/customize.gemspec
CHANGED
@@ -11,6 +11,7 @@ module Customize
|
|
11
11
|
|
12
12
|
def character
|
13
13
|
@character ||= proc {
|
14
|
+
ascent_ids = self.class.include?(Customize::Inherited) ? self.ascent_ids : []
|
14
15
|
all_character = Character.where(:related_id=>(ascent_ids | [self.id]), :related_type=>self.class.name)
|
15
16
|
all_character.inject(HashWithIndifferentAccess.new) { |map, item|
|
16
17
|
map[item.key] = item.value
|
data/lib/customize/inherited.rb
CHANGED
@@ -14,53 +14,67 @@ describe Customize::Characterize do
|
|
14
14
|
end
|
15
15
|
end
|
16
16
|
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
17
|
+
with_model :person do
|
18
|
+
table do |t|
|
19
|
+
end
|
20
|
+
model do
|
21
|
+
include Customize::Characterize
|
22
|
+
end
|
21
23
|
end
|
22
24
|
|
23
|
-
context
|
25
|
+
context :model_without_inherit do
|
26
|
+
subject { Person.create }
|
24
27
|
|
25
|
-
|
26
|
-
|
27
|
-
@type = example.metadata[:type]
|
28
|
-
subject.characters.create :key=>@type, :type=>@type, :value=>@value
|
28
|
+
it :has_character do
|
29
|
+
subject.characters.create :key=>:foo, :type=>:boolean, :value=>true
|
29
30
|
subject.reload
|
31
|
+
subject.character[:foo].should be_true
|
30
32
|
end
|
31
33
|
|
32
|
-
|
33
|
-
subject.character[@type].should == @value
|
34
|
-
end
|
34
|
+
end
|
35
35
|
|
36
|
-
|
36
|
+
context :model_with_inherit do
|
37
|
+
subject { Product.create! }
|
38
|
+
|
39
|
+
it "has characters" do
|
40
|
+
subject.characters.should_not be_nil
|
37
41
|
end
|
38
|
-
|
39
|
-
|
42
|
+
|
43
|
+
context "support type" do
|
44
|
+
before :each do
|
45
|
+
@value = example.metadata[:description_args].first
|
46
|
+
@type = example.metadata[:type]
|
47
|
+
subject.characters.create :key=>@type, :type=>@type, :value=>@value
|
48
|
+
subject.reload
|
49
|
+
end
|
50
|
+
|
51
|
+
after :each do
|
52
|
+
subject.character[@type].should == @value
|
53
|
+
end
|
54
|
+
|
55
|
+
it 10, :type=>:integer do
|
56
|
+
end
|
57
|
+
it 12.34, :type=>:decimal do
|
58
|
+
end
|
59
|
+
it 'string', :type=>:string do
|
60
|
+
end
|
61
|
+
it [1, 2, 3] do
|
62
|
+
end
|
63
|
+
it Hash.new(:foo=>:bar) do
|
64
|
+
end
|
40
65
|
end
|
41
|
-
|
42
|
-
it
|
66
|
+
|
67
|
+
it "has readonly hash character" do
|
68
|
+
subject.characters.create! :key=>:foo, :value=>'bar'
|
69
|
+
subject.character[:foo].should == 'bar'
|
43
70
|
end
|
44
|
-
|
45
|
-
it
|
46
|
-
|
47
|
-
|
48
|
-
|
71
|
+
|
72
|
+
it "has inherited character" do
|
73
|
+
parent = Product.create!
|
74
|
+
parent.characters.create! :key=>:p, :value=>1
|
75
|
+
subject.inherit parent
|
76
|
+
subject.character[:p].should == 1
|
49
77
|
end
|
50
|
-
|
51
78
|
end
|
52
79
|
|
53
|
-
it "has readonly hash character" do
|
54
|
-
subject.characters.create! :key=>:foo, :value=>'bar'
|
55
|
-
subject.character[:foo].should == 'bar'
|
56
|
-
end
|
57
|
-
|
58
|
-
it "has inherited character" do
|
59
|
-
parent = Product.create!
|
60
|
-
parent.characters.create! :key=>:p, :value=>1
|
61
|
-
subject.inherit parent
|
62
|
-
subject.character[:p].should == 1
|
63
|
-
end
|
64
|
-
|
65
|
-
|
66
80
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: customize
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.3
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -265,7 +265,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
265
265
|
version: '0'
|
266
266
|
segments:
|
267
267
|
- 0
|
268
|
-
hash:
|
268
|
+
hash: 348052147
|
269
269
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
270
270
|
none: false
|
271
271
|
requirements:
|