active_store 0.0.3 → 0.0.4

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/.gitignore CHANGED
@@ -1,5 +1,4 @@
1
1
  *.gem
2
2
  .bundle
3
- Gemfile.lock
4
3
  pkg/*
5
4
  .idea/
data/Gemfile CHANGED
@@ -1,8 +1,5 @@
1
1
  source "http://rubygems.org"
2
2
 
3
- # Specify your gem's dependencies in active_store.gemspec
4
- gem 'activesupport', '3.0.11'
5
-
6
3
  platforms :jruby do
7
4
  gem 'json-jruby', :require => 'json'
8
5
  end
data/Gemfile.lock ADDED
@@ -0,0 +1,33 @@
1
+ PATH
2
+ remote: .
3
+ specs:
4
+ active_store (0.0.4)
5
+ dalli
6
+
7
+ GEM
8
+ remote: http://rubygems.org/
9
+ specs:
10
+ dalli (1.1.5)
11
+ diff-lcs (1.1.3)
12
+ json (1.5.0-java)
13
+ json-jruby (1.5.0-java)
14
+ json (= 1.5.0)
15
+ rake (0.9.2.2)
16
+ rspec (2.9.0)
17
+ rspec-core (~> 2.9.0)
18
+ rspec-expectations (~> 2.9.0)
19
+ rspec-mocks (~> 2.9.0)
20
+ rspec-core (2.9.0)
21
+ rspec-expectations (2.9.0)
22
+ diff-lcs (~> 1.1.3)
23
+ rspec-mocks (2.9.0)
24
+
25
+ PLATFORMS
26
+ java
27
+ ruby
28
+
29
+ DEPENDENCIES
30
+ active_store!
31
+ json-jruby
32
+ rake
33
+ rspec
data/active_store.gemspec CHANGED
@@ -22,5 +22,4 @@ Gem::Specification.new do |s|
22
22
  s.add_development_dependency "rspec"
23
23
  s.add_development_dependency "rake"
24
24
  s.add_runtime_dependency "dalli"
25
- s.add_runtime_dependency "activesupport"
26
25
  end
@@ -1,5 +1,3 @@
1
- require 'active_support/core_ext/hash/indifferent_access'
2
-
3
1
  module ActiveStore
4
2
  class Base
5
3
 
@@ -9,19 +7,19 @@ module ActiveStore
9
7
  end
10
8
 
11
9
  def ==(another_object)
12
- (self.class.attributes - [:created_at]).all? do |attribute|
10
+ (self.class.attributes - ["created_at"]).all? do |attribute|
13
11
  self.send(attribute) == another_object.send(attribute)
14
12
  end
15
13
  end
16
14
 
17
15
  def attributes
18
- self.class.attributes.inject(HashWithIndifferentAccess.new) do |accu, attribute|
16
+ self.class.attributes.inject({}) do |accu, attribute|
19
17
  send(attribute).nil? ? accu : accu.merge({attribute => send(attribute)})
20
18
  end
21
19
  end
22
20
 
23
21
  def set_attributes(params = {})
24
- params = params.with_indifferent_access
22
+ params = Hash[ params.map {|key, value| [key.to_s, value]} ]
25
23
  self.class.attributes.each do |attribute|
26
24
  write_attribute(attribute, params[attribute])
27
25
  end
@@ -74,8 +72,8 @@ module ActiveStore
74
72
 
75
73
  def define_attributes(*args)
76
74
  @attributes ||= []
77
- @attributes += args
78
- @attributes |= [:id, :created_at]
75
+ @attributes += args.map(&:to_s)
76
+ @attributes |= ["id", "created_at"]
79
77
  attr_accessor *@attributes
80
78
  end
81
79
 
@@ -128,7 +126,7 @@ module ActiveStore
128
126
 
129
127
  def create_with_block(id, ttl = default_ttl, &block)
130
128
  block = attributes_block_wrapper(&block)
131
- connection.add(id, block.call({:id => id}), ttl)
129
+ connection.add(id, block.call({"id" => id}), ttl)
132
130
  end
133
131
 
134
132
  def find(id)
@@ -1,3 +1,3 @@
1
1
  module ActiveStore
2
- VERSION = "0.0.3"
2
+ VERSION = "0.0.4"
3
3
  end
@@ -54,7 +54,7 @@ describe ActiveStore::Base do
54
54
  end
55
55
 
56
56
  it "lists attibute names" do
57
- ItemStore.attributes.should include :a1, :a2
57
+ ItemStore.attributes.should include "a1", "a2"
58
58
  end
59
59
 
60
60
  it "provides accessors for its attributes" do
@@ -66,7 +66,7 @@ describe ActiveStore::Base do
66
66
 
67
67
  describe ".define_attributes" do
68
68
  it "should add id and created_at in attributes" do
69
- ItemStore.attributes.should include :id, :created_at
69
+ ItemStore.attributes.should include "id", "created_at"
70
70
  end
71
71
  it "should add id and created_at in its instance accessors" do
72
72
  ItemStore.new.methods.map(&:to_sym).should include :id, :id=, :created_at, :created_at=
@@ -77,14 +77,14 @@ describe ActiveStore::Base do
77
77
  it "initializes given attributes" do
78
78
  params = { :a1 => "one", :a2 => "two" }
79
79
  item = ItemStore.new params
80
- item.attributes[:a1].should == params[:a1]
81
- item.attributes[:a2].should == params[:a2]
80
+ item.attributes["a1"].should == params[:a1]
81
+ item.attributes["a2"].should == params[:a2]
82
82
  end
83
83
  it "initializes attributes even when the params keys are strings" do
84
84
  params = { "a1" => "one", "a2" => "two" }
85
85
  item = ItemStore.new params
86
- item.attributes[:a1].should == params["a1"]
87
- item.attributes[:a2].should == params["a2"]
86
+ item.attributes["a1"].should == params["a1"]
87
+ item.attributes["a2"].should == params["a2"]
88
88
  end
89
89
  it "doesn't require attributes" do
90
90
  ItemStore.new.a1.should be_nil
@@ -97,7 +97,7 @@ describe ActiveStore::Base do
97
97
  end
98
98
  it "can set attribute to false" do
99
99
  item = ItemStore.new "a1" => false
100
- item.attributes[:a1].should == false
100
+ item.attributes["a1"].should == false
101
101
  end
102
102
  end
103
103
 
metadata CHANGED
@@ -2,7 +2,7 @@
2
2
  name: active_store
3
3
  version: !ruby/object:Gem::Version
4
4
  prerelease:
5
- version: 0.0.3
5
+ version: 0.0.4
6
6
  platform: ruby
7
7
  authors:
8
8
  - Petter Remen
@@ -46,17 +46,6 @@ dependencies:
46
46
  version: "0"
47
47
  type: :runtime
48
48
  version_requirements: *id003
49
- - !ruby/object:Gem::Dependency
50
- name: activesupport
51
- prerelease: false
52
- requirement: &id004 !ruby/object:Gem::Requirement
53
- none: false
54
- requirements:
55
- - - ">="
56
- - !ruby/object:Gem::Version
57
- version: "0"
58
- type: :runtime
59
- version_requirements: *id004
60
49
  description: ""
61
50
  email:
62
51
  - petter@icehouse.se
@@ -72,6 +61,7 @@ files:
72
61
  - .rspec
73
62
  - .rvmrc
74
63
  - Gemfile
64
+ - Gemfile.lock
75
65
  - README
76
66
  - Rakefile
77
67
  - active_store.gemspec