toystore 0.6.4 → 0.6.5

Sign up to get free protection for your applications and to get access to all the features.
data/.gitignore CHANGED
@@ -4,4 +4,5 @@ testing/
4
4
  log
5
5
  tmp
6
6
  pkg
7
- .bundle
7
+ .bundle
8
+ Gemfile.lock
data/lib/toy.rb CHANGED
@@ -10,7 +10,6 @@ require 'simple_uuid'
10
10
  require 'active_model'
11
11
  require 'active_support/json'
12
12
  require 'active_support/core_ext/object'
13
- require 'active_support/core_ext/hash/indifferent_access'
14
13
  require 'active_support/core_ext/hash/keys'
15
14
  require 'active_support/core_ext/class/inheritable_attributes'
16
15
  require 'active_support/core_ext/string/conversions'
data/lib/toy/attribute.rb CHANGED
@@ -5,11 +5,11 @@ module Toy
5
5
  def initialize(model, name, type, options={})
6
6
  options.assert_valid_keys(:default, :embedded_list, :virtual, :abbr)
7
7
 
8
- @model, @name, @type, @options = model, name.to_sym, type, options
8
+ @model, @name, @type, @options = model, name.to_s, type, options
9
9
  @virtual = options.fetch(:virtual, false)
10
10
 
11
11
  if abbr?
12
- options[:abbr] = abbr.to_sym
12
+ options[:abbr] = abbr.to_s
13
13
  model.alias_attribute(abbr, name)
14
14
  end
15
15
 
@@ -55,7 +55,7 @@ module Toy
55
55
  end
56
56
 
57
57
  def store_key
58
- (abbr? ? abbr : name).to_s
58
+ abbr? ? abbr : name
59
59
  end
60
60
 
61
61
  # Stores reference to related embedded list
@@ -99,11 +99,11 @@ module Toy
99
99
 
100
100
  private
101
101
  def read_attribute(key)
102
- @attributes[key]
102
+ @attributes[key.to_s]
103
103
  end
104
104
 
105
105
  def write_attribute(key, value)
106
- @attributes[key] = attribute_definition(key).try(:from_store, value)
106
+ @attributes[key.to_s] = attribute_definition(key).try(:from_store, value)
107
107
  end
108
108
 
109
109
  def attribute_definition(key)
@@ -127,9 +127,9 @@ module Toy
127
127
  end
128
128
 
129
129
  def initialize_attributes_with_defaults
130
- @attributes = {}.with_indifferent_access
130
+ @attributes = {}
131
131
  self.class.defaulted_attributes.each do |attribute|
132
- @attributes[attribute.name] = attribute.default
132
+ @attributes[attribute.name.to_s] = attribute.default
133
133
  end
134
134
  end
135
135
  end
data/lib/toy/dolly.rb CHANGED
@@ -5,7 +5,7 @@ module Toy
5
5
  def initialize_copy(other)
6
6
  @_new_record = true
7
7
  @_destroyed = false
8
- @attributes = {}.with_indifferent_access
8
+ @attributes = {}
9
9
 
10
10
  self.class.embedded_lists.each do |name, list|
11
11
  instance_variable_set(list.instance_variable, nil)
@@ -2,11 +2,11 @@ module Toy
2
2
  module Extensions
3
3
  module Hash
4
4
  def store_default
5
- {}.with_indifferent_access
5
+ {}
6
6
  end
7
7
 
8
8
  def from_store(value, *)
9
- value.nil? ? store_default : value.with_indifferent_access
9
+ value.nil? ? store_default : value
10
10
  end
11
11
  end
12
12
  end
data/lib/toy/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  module Toy
2
- VERSION = "0.6.4"
2
+ VERSION = "0.6.5"
3
3
  end
@@ -14,7 +14,7 @@ describe Toy::Attribute do
14
14
  end
15
15
 
16
16
  it "has name" do
17
- attribute.name.should == :age
17
+ attribute.name.should == 'age'
18
18
  end
19
19
 
20
20
  it "has type" do
@@ -152,11 +152,11 @@ describe Toy::Attribute do
152
152
 
153
153
  describe "#abbr" do
154
154
  it "returns abbr if present" do
155
- Toy::Attribute.new(User, :twitter_access_token, String, :abbr => :tat).abbr.should == :tat
155
+ Toy::Attribute.new(User, :twitter_access_token, String, :abbr => :tat).abbr.should == 'tat'
156
156
  end
157
157
 
158
158
  it "returns abbr as symbol if present as string" do
159
- Toy::Attribute.new(User, :twitter_access_token, String, :abbr => 'tat').abbr.should == :tat
159
+ Toy::Attribute.new(User, :twitter_access_token, String, :abbr => 'tat').abbr.should == 'tat'
160
160
  end
161
161
 
162
162
  it "returns nil if not present" do
@@ -1,21 +1,19 @@
1
1
  require 'helper'
2
2
 
3
3
  describe "Hash.from_store" do
4
- it "should convert hash to hash with indifferent access" do
5
- hash = Hash.from_store(:foo => 'bar')
6
- hash[:foo].should == 'bar'
7
- hash['foo'].should == 'bar'
4
+ it "should return hash" do
5
+ Hash.from_store(:foo => 'bar')[:foo].should == 'bar'
6
+ Hash.from_store('foo' => 'bar')['foo'].should == 'bar'
8
7
  end
9
8
 
10
9
  it "should be hash if nil" do
11
10
  hash = Hash.from_store(nil)
12
11
  hash.should == {}
13
- hash.is_a?(HashWithIndifferentAccess).should be_true
14
12
  end
15
13
  end
16
14
 
17
15
  describe "Hash.store_default" do
18
- it "returns emtpy hash with indifferent access" do
19
- Hash.store_default.should == {}.with_indifferent_access
16
+ it "returns emtpy hash" do
17
+ Hash.store_default.should == {}
20
18
  end
21
19
  end
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: toystore
3
3
  version: !ruby/object:Gem::Version
4
- hash: 15
4
+ hash: 13
5
5
  prerelease: false
6
6
  segments:
7
7
  - 0
8
8
  - 6
9
- - 4
10
- version: 0.6.4
9
+ - 5
10
+ version: 0.6.5
11
11
  platform: ruby
12
12
  authors:
13
13
  - Geoffrey Dagley
@@ -16,7 +16,7 @@ autorequire:
16
16
  bindir: bin
17
17
  cert_chain: []
18
18
 
19
- date: 2011-02-13 00:00:00 -05:00
19
+ date: 2011-04-15 00:00:00 -04:00
20
20
  default_executable:
21
21
  dependencies:
22
22
  - !ruby/object:Gem::Dependency
@@ -97,7 +97,6 @@ files:
97
97
  - .autotest
98
98
  - .gitignore
99
99
  - Gemfile
100
- - Gemfile.lock
101
100
  - LICENSE
102
101
  - LOGGING.rdoc
103
102
  - README.rdoc
data/Gemfile.lock DELETED
@@ -1,57 +0,0 @@
1
- PATH
2
- remote: .
3
- specs:
4
- toystore (0.6.3)
5
- activemodel (~> 3.0.3)
6
- activesupport (~> 3.0.3)
7
- adapter (~> 0.5.1)
8
- simple_uuid (~> 0.1.1)
9
-
10
- GEM
11
- remote: http://rubygems.org/
12
- specs:
13
- activemodel (3.0.3)
14
- activesupport (= 3.0.3)
15
- builder (~> 2.1.2)
16
- i18n (~> 0.4)
17
- activesupport (3.0.3)
18
- adapter (0.5.1)
19
- bson (1.2.0)
20
- bson_ext (1.2.0)
21
- builder (2.1.2)
22
- diff-lcs (1.1.2)
23
- i18n (0.5.0)
24
- log_buddy (0.5.0)
25
- rack (1.2.1)
26
- rack-test (0.5.7)
27
- rack (>= 1.0)
28
- rake (0.8.7)
29
- rspec (2.4.0)
30
- rspec-core (~> 2.4.0)
31
- rspec-expectations (~> 2.4.0)
32
- rspec-mocks (~> 2.4.0)
33
- rspec-core (2.4.0)
34
- rspec-expectations (2.4.0)
35
- diff-lcs (~> 1.1.2)
36
- rspec-mocks (2.4.0)
37
- simple_uuid (0.1.1)
38
- timecop (0.3.5)
39
- tzinfo (0.3.23)
40
-
41
- PLATFORMS
42
- ruby
43
-
44
- DEPENDENCIES
45
- activemodel (~> 3.0.3)
46
- activesupport (~> 3.0.3)
47
- adapter (~> 0.5.1)
48
- bson
49
- bson_ext
50
- log_buddy (~> 0.5.0)
51
- rack-test
52
- rake (~> 0.8.7)
53
- rspec (~> 2.3)
54
- simple_uuid (~> 0.1.1)
55
- timecop (~> 0.3.5)
56
- toystore!
57
- tzinfo (~> 0.3.23)