serial_preference 1.1.1 → 1.1.2

Sign up to get free protection for your applications and to get access to all the features.
@@ -34,17 +34,17 @@ module SerialPreference
34
34
 
35
35
  key = preference.name
36
36
  define_method("#{key}=") do |value|
37
- write_preference_attribute(_preferences_attribute,key,self.class.preference_definition(key).value(value))
37
+ write_preference_attribute(self.class._preferences_attribute,key,self.class.preference_definition(key).value(value))
38
38
  end
39
39
 
40
40
  define_method(key) do
41
- value = read_preference_attribute(_preferences_attribute,key)
41
+ value = read_preference_attribute(self.class._preferences_attribute,key)
42
42
  self.class.preference_definition(key).value(value)
43
43
  end
44
44
 
45
45
  if preference.boolean?
46
46
  define_method("#{key}?") do
47
- read_preference_attribute(_preferences_attribute,key).present?
47
+ read_preference_attribute(self.class._preferences_attribute,key).present?
48
48
  end
49
49
  end
50
50
 
@@ -56,14 +56,14 @@ module SerialPreference
56
56
 
57
57
  def read_preference_attribute(store_attribute, key)
58
58
  attribute = send(store_attribute)
59
- attribute[key]
59
+ attribute[key.to_sym]
60
60
  end
61
61
 
62
62
  def write_preference_attribute(store_attribute, key, value)
63
63
  attribute = send(store_attribute)
64
64
  if value != attribute[key]
65
65
  send :"#{store_attribute}_will_change!"
66
- attribute[key] = value
66
+ attribute[key.to_sym] = value
67
67
  end
68
68
  end
69
69
 
@@ -1,3 +1,3 @@
1
1
  module SerialPreference
2
- VERSION = "1.1.1"
2
+ VERSION = "1.1.2"
3
3
  end
@@ -43,6 +43,12 @@ describe SerialPreference::HasSerialPreferences do
43
43
  d.respond_to?(:write_preference_attribute).should be_true
44
44
  end
45
45
 
46
+ it "should ensure that the readers returns the correct data" do
47
+ d = DummyClass.new
48
+ d.preferences = {:vat_no => "abc"}
49
+ d.vat_no.should eq("abc")
50
+ end
51
+
46
52
  it "should have writers available" do
47
53
  d = DummyClass.new
48
54
  d.respond_to?(:taxable=).should be_true
@@ -51,12 +57,27 @@ describe SerialPreference::HasSerialPreferences do
51
57
  d.respond_to?(:income_ledger_id=).should be_true
52
58
  end
53
59
 
60
+ it "should ensure that the writer write the correct data" do
61
+ d = DummyClass.new
62
+ d.vat_no = "abc"
63
+ d.vat_no.should eq("abc")
64
+ end
65
+
66
+ it "should ensure that the querier the correct data" do
67
+ d = DummyClass.new
68
+ d.taxable = true
69
+ d.should be_taxable
70
+ d.taxable = false
71
+ d.should_not be_taxable
72
+ end
73
+
54
74
  it "should have query methods available for booleans" do
55
75
  DummyClass.new.respond_to?(:taxable?)
56
76
  end
57
-
58
77
  end
59
78
 
79
+
80
+
60
81
  =begin
61
82
  context "should define validations" do
62
83
  it "should define presence validation on required preferences" do
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: serial_preference
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.1.1
4
+ version: 1.1.2
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -130,7 +130,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
130
130
  version: '0'
131
131
  segments:
132
132
  - 0
133
- hash: -808331589467144063
133
+ hash: 4541839474087512825
134
134
  required_rubygems_version: !ruby/object:Gem::Requirement
135
135
  none: false
136
136
  requirements:
@@ -139,7 +139,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
139
139
  version: '0'
140
140
  segments:
141
141
  - 0
142
- hash: -808331589467144063
142
+ hash: 4541839474087512825
143
143
  requirements: []
144
144
  rubyforge_project:
145
145
  rubygems_version: 1.8.24