hashie 0.1.5 → 0.1.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.
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.1.5
1
+ 0.1.6
@@ -5,11 +5,11 @@
5
5
 
6
6
  Gem::Specification.new do |s|
7
7
  s.name = %q{hashie}
8
- s.version = "0.1.5"
8
+ s.version = "0.1.6"
9
9
 
10
10
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
11
  s.authors = ["Michael Bleigh"]
12
- s.date = %q{2009-11-16}
12
+ s.date = %q{2010-01-13}
13
13
  s.description = %q{Hashie is a small collection of tools that make hashes more powerful. Currently includes Mash (Mocking Hash) and Dash (Discrete Hash).}
14
14
  s.email = %q{michael@intridea.com}
15
15
  s.extra_rdoc_files = [
@@ -26,8 +26,8 @@ module Hashie
26
26
  def self.property(property_name, options = {})
27
27
  property_name = property_name.to_sym
28
28
 
29
- (@properties ||= []) << property_name
30
- (@defaults ||= {})[property_name] = options.delete(:default)
29
+ (@@properties ||= []) << property_name
30
+ (@@defaults ||= {})[property_name] = options.delete(:default)
31
31
 
32
32
  class_eval <<-RUBY
33
33
  def #{property_name}
@@ -43,7 +43,7 @@ module Hashie
43
43
  # Get a String array of the currently defined
44
44
  # properties on this Dash.
45
45
  def self.properties
46
- @properties.collect{|p| p.to_s}
46
+ @@properties.collect{|p| p.to_s}
47
47
  end
48
48
 
49
49
  # Check to see if the specified property has already been
@@ -54,7 +54,7 @@ module Hashie
54
54
 
55
55
  # The default values that have been set for this Dash
56
56
  def self.defaults
57
- @defaults
57
+ @@defaults
58
58
  end
59
59
 
60
60
  # You may initialize a Dash with an attributes hash
@@ -141,7 +141,7 @@ module Hashie
141
141
  case val
142
142
  when ::Hash
143
143
  val = val.dup if duping
144
- Hashie::Mash.new(val)
144
+ self.class.new(val)
145
145
  when Array
146
146
  val.collect{ |e| convert_value(e) }
147
147
  else
@@ -6,6 +6,9 @@ class DashTest < Hashie::Dash
6
6
  property :count, :default => 0
7
7
  end
8
8
 
9
+ class Subclassed < DashTest
10
+ end
11
+
9
12
  describe Hashie::Dash do
10
13
  it 'should be a subclass of Hashie::Hash' do
11
14
  (Hashie::Dash < Hash).should be_true
@@ -77,4 +80,18 @@ describe Hashie::Dash do
77
80
  DashTest.new.defaulted.should == 'abc'
78
81
  end
79
82
  end
83
+ end
84
+
85
+ describe Subclassed do
86
+ it "should inherit all properties from DashTest" do
87
+ Subclassed.properties.size.should == 5
88
+ end
89
+
90
+ it "should inherit all defaults from DashTest" do
91
+ Subclassed.defaults.size.should == 5
92
+ end
93
+
94
+ it "should init without raising" do
95
+ lambda { Subclassed.new }.should_not raise_error
96
+ end
80
97
  end
@@ -74,6 +74,15 @@ describe Hashie::Mash do
74
74
  @mash.details.address.state.should == 'TX'
75
75
  end
76
76
 
77
+ it "should not convert the type of Hashie::Mashes childs to Hashie::Mash" do
78
+ class MyMash < Hashie::Mash
79
+ end
80
+
81
+ record = MyMash.new
82
+ record.son = MyMash.new
83
+ record.son.class.should == MyMash
84
+ end
85
+
77
86
  context "#initialize" do
78
87
  it "should convert an existing hash to a Hashie::Mash" do
79
88
  converted = Hashie::Mash.new({:abc => 123, :name => "Bob"})
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: hashie
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.5
4
+ version: 0.1.6
5
5
  platform: ruby
6
6
  authors:
7
7
  - Michael Bleigh
@@ -9,7 +9,7 @@ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
11
 
12
- date: 2009-11-16 00:00:00 -08:00
12
+ date: 2010-01-13 00:00:00 -05:00
13
13
  default_executable:
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency