objectify 0.0.2 → 0.0.3

Sign up to get free protection for your applications and to get access to all the features.
data/Gemfile.lock CHANGED
@@ -1,11 +1,13 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- objectify (0.0.1)
4
+ objectify (0.0.2)
5
+ activesupport (>= 2.3)
5
6
 
6
7
  GEM
7
8
  remote: http://rubygems.org/
8
9
  specs:
10
+ activesupport (3.0.5)
9
11
  diff-lcs (1.1.2)
10
12
  rake (0.8.7)
11
13
  rspec (2.5.0)
@@ -1,3 +1,3 @@
1
1
  module Objectify
2
- VERSION = "0.0.2"
2
+ VERSION = "0.0.3"
3
3
  end
data/lib/objectify.rb CHANGED
@@ -1,20 +1,22 @@
1
- module Objectify
2
- class Proxy
3
- def == other
4
- @target == other
5
- end
1
+ require 'active_support'
6
2
 
3
+ module Objectify
4
+ class Proxy < ActiveSupport::BasicObject
7
5
  def initialize target
8
6
  @target = target
9
7
  end
10
8
 
11
9
  def method_missing name, *args, &block
12
- if @target.is_a?(Hash) && @target.has_key?(name)
10
+ if @target.respond_to?(:has_key?) && @target.has_key?(name)
13
11
  Proxy.new @target[name]
14
12
  else
15
13
  Proxy.new @target.send(name, *args, &block)
16
14
  end
17
15
  end
16
+
17
+ def send name, *args, &block
18
+ method_missing name.to_sym, *args, &block
19
+ end
18
20
  end
19
21
 
20
22
  def objectify
data/objectify.gemspec CHANGED
@@ -19,6 +19,7 @@ Gem::Specification.new do |s|
19
19
  s.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
20
20
  s.require_paths = ["lib"]
21
21
 
22
+ s.add_dependency('activesupport', '>= 2.3')
22
23
  s.add_development_dependency('rspec')
23
24
  s.add_development_dependency('rake')
24
25
  end
@@ -7,7 +7,8 @@ describe "an objectified hash" do
7
7
  subject { {:key => "value", :another_key => "another value"}.objectify }
8
8
 
9
9
  its(:key) { should == "value" }
10
- its(:another_key) { should == "another value" }
10
+ it { subject.another_key.should == "another value" }
11
+ it { subject.send(:key).should == "value" }
11
12
  end
12
13
 
13
14
  describe "an objectified hash with nested hashes" do
metadata CHANGED
@@ -2,7 +2,7 @@
2
2
  name: objectify
3
3
  version: !ruby/object:Gem::Version
4
4
  prerelease:
5
- version: 0.0.2
5
+ version: 0.0.3
6
6
  platform: ruby
7
7
  authors:
8
8
  - Andrew Kiellor
@@ -10,22 +10,22 @@ autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
12
 
13
- date: 2011-03-07 00:00:00 +11:00
13
+ date: 2011-03-14 00:00:00 +11:00
14
14
  default_executable:
15
15
  dependencies:
16
16
  - !ruby/object:Gem::Dependency
17
- name: rspec
17
+ name: activesupport
18
18
  prerelease: false
19
19
  requirement: &id001 !ruby/object:Gem::Requirement
20
20
  none: false
21
21
  requirements:
22
22
  - - ">="
23
23
  - !ruby/object:Gem::Version
24
- version: "0"
25
- type: :development
24
+ version: "2.3"
25
+ type: :runtime
26
26
  version_requirements: *id001
27
27
  - !ruby/object:Gem::Dependency
28
- name: rake
28
+ name: rspec
29
29
  prerelease: false
30
30
  requirement: &id002 !ruby/object:Gem::Requirement
31
31
  none: false
@@ -35,6 +35,17 @@ dependencies:
35
35
  version: "0"
36
36
  type: :development
37
37
  version_requirements: *id002
38
+ - !ruby/object:Gem::Dependency
39
+ name: rake
40
+ prerelease: false
41
+ requirement: &id003 !ruby/object:Gem::Requirement
42
+ none: false
43
+ requirements:
44
+ - - ">="
45
+ - !ruby/object:Gem::Version
46
+ version: "0"
47
+ type: :development
48
+ version_requirements: *id003
38
49
  description: A simple gem to make hashes and arrays of hashes behave like objects using proxies.
39
50
  email:
40
51
  - akiellor@gmail.com