activerecord-hstore_properties 0.0.6 → 0.0.9

Sign up to get free protection for your applications and to get access to all the features.
@@ -48,7 +48,7 @@ module ActiveRecord
48
48
  properties.each do |property|
49
49
  property.class.property_accessors.each do |suffixes, proc|
50
50
 
51
- method_names = suffixes.map{|suffix| "#{property.name}#{suffix}"}
51
+ method_names = suffixes.map { |suffix| "#{property.name}#{suffix}" }
52
52
  primary_method_name = method_names.shift
53
53
 
54
54
  #Define main method once...
@@ -57,7 +57,11 @@ module ActiveRecord
57
57
  end
58
58
 
59
59
  #... and then define aliases
60
- method_names.each { |method_name| alias_method(method_name, primary_method_name) }
60
+ method_names.each do |method_name|
61
+ unless method_defined?(method_name)
62
+ alias_method(method_name, primary_method_name)
63
+ end
64
+ end
61
65
  end
62
66
  end
63
67
  end
@@ -12,17 +12,17 @@ module ActiveRecord
12
12
  end
13
13
 
14
14
  add_property_accessor '_raise!', '_enable!' do |property|
15
- _properties = self.properties
16
- _properties[property.name] = true
17
- update_column(:properties, ActiveRecord::Coders::Hstore.new({}).dump(_properties))
18
- _properties[property.name]
15
+ properties_will_change!
16
+ properties[property.name] = true
17
+ save
18
+ properties[property.name]
19
19
  end
20
20
 
21
21
  add_property_accessor '_lower!', '_disable!' do |property|
22
- _properties = self.properties
23
- _properties[property.name] = false
24
- update_column(:properties, ActiveRecord::Coders::Hstore.new({}).dump(_properties))
25
- _properties[property.name]
22
+ properties_will_change!
23
+ properties[property.name] = false
24
+ save
25
+ properties[property.name]
26
26
  end
27
27
  end
28
28
  end
@@ -3,7 +3,7 @@ module ActiveRecord
3
3
  module CommonAccessors
4
4
  extend ActiveSupport::Concern
5
5
  included do
6
- add_property_accessor '_property' do |property|
6
+ add_property_accessor '_property' do |property|
7
7
  properties[property.name.to_s]
8
8
  end
9
9
 
@@ -12,10 +12,10 @@ module ActiveRecord
12
12
  end
13
13
 
14
14
  add_property_accessor '_bump!' do |property|
15
- _properties = properties
16
- _properties[property.name] = properties[property.name].to_i + 1
17
- update_column(:properties, ActiveRecord::Coders::Hstore.new({}).dump(_properties))
18
- _properties[property.name]
15
+ properties_will_change!
16
+ properties[property.name] = properties[property.name].to_i + 1
17
+ save
18
+ properties[property.name]
19
19
  end
20
20
 
21
21
  end
@@ -1,5 +1,5 @@
1
1
  module Activerecord
2
2
  module HstoreProperties
3
- VERSION = "0.0.6"
3
+ VERSION = "0.0.9"
4
4
  end
5
5
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: activerecord-hstore_properties
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.6
4
+ version: 0.0.9
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2013-04-12 00:00:00.000000000 Z
12
+ date: 2013-04-16 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: activesupport