activerecord-hstore_properties 0.0.5 → 0.0.6

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.
@@ -9,7 +9,7 @@ Gem::Specification.new do |gem|
9
9
  gem.authors = ["stevo"]
10
10
  gem.email = ["blazej.kosmowski@selleo.com"]
11
11
  gem.homepage = "https://github.com/stevo/activerecord-hstore_properties"
12
- gem.summary = "Facilitate defining and retrieving information from hstore column"
12
+ gem.summary = "hStore-based model properties on steroids!"
13
13
  gem.description = "Allows to describe field names that will be stored within hstore column together with their types. Data can then be retrieved with a set of helpful getters."
14
14
 
15
15
  gem.files = `git ls-files`.split($/)
@@ -63,9 +63,9 @@ module ActiveRecord
63
63
  end
64
64
 
65
65
  def extract_properties(args)
66
- typed_properties = args.extract_options!
66
+ typed_properties = args.extract_options!.stringify_keys
67
67
 
68
- result = args.map { |property| default_property_klass.new(property) }
68
+ result = args.map { |property| default_property_klass.new(property.to_s) }
69
69
  typed_properties.each do |property, _type|
70
70
  result << "active_record/properties/#{_type.to_s}_property".camelize.constantize.new(property)
71
71
  end
@@ -1,7 +1,11 @@
1
1
  module ActiveRecord
2
2
  module Properties
3
- class Base < Struct.new(:name)
3
+ class Base
4
4
  class_attribute :_property_accessors
5
+ attr_reader :name
6
+ def initialize(name)
7
+ @name = name.to_s
8
+ end
5
9
 
6
10
  class << self
7
11
  def property_accessors
@@ -9,7 +9,7 @@ module ActiveRecord
9
9
 
10
10
  add_property_accessor '=' do |property, *args|
11
11
  properties_will_change!
12
- properties[property.name.to_s] = args.shift
12
+ properties[property.name] = args.shift
13
13
  end
14
14
  end
15
15
  end
@@ -12,8 +12,8 @@ module ActiveRecord
12
12
  end
13
13
 
14
14
  add_property_accessor '_bump!' do |property|
15
- _properties = self.properties
16
- _properties[property.name] = self[property.name].to_i + 1
15
+ _properties = properties
16
+ _properties[property.name] = properties[property.name].to_i + 1
17
17
  update_column(:properties, ActiveRecord::Coders::Hstore.new({}).dump(_properties))
18
18
  _properties[property.name]
19
19
  end
@@ -1,5 +1,5 @@
1
1
  module Activerecord
2
2
  module HstoreProperties
3
- VERSION = "0.0.5"
3
+ VERSION = "0.0.6"
4
4
  end
5
5
  end
@@ -96,6 +96,8 @@ describe ActiveRecord::HstoreProperties do
96
96
  it "should be possible to bump counter" do
97
97
  @comment.property_two_bump!
98
98
  @comment.properties['property_two'].should == '1'
99
+ @comment.property_two_bump!
100
+ @comment.properties['property_two'].should == '2'
99
101
  end
100
102
 
101
103
  it "should be possible to query for current count" do
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.5
4
+ version: 0.0.6
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -191,7 +191,7 @@ rubyforge_project:
191
191
  rubygems_version: 1.8.24
192
192
  signing_key:
193
193
  specification_version: 3
194
- summary: Facilitate defining and retrieving information from hstore column
194
+ summary: hStore-based model properties on steroids!
195
195
  test_files:
196
196
  - spec/hstore_properties_spec.rb
197
197
  - spec/spec_helper.rb