diff options
-rw-r--r-- | lib/hashie/dash.rb | 8 | ||||
-rw-r--r-- | spec/hashie/dash_spec.rb | 13 |
2 files changed, 17 insertions, 4 deletions
diff --git a/lib/hashie/dash.rb b/lib/hashie/dash.rb index 47b0afe..3d73090 100644 --- a/lib/hashie/dash.rb +++ b/lib/hashie/dash.rb @@ -26,8 +26,8 @@ module Hashie def self.property(property_name, options = {}) property_name = property_name.to_sym - (@properties ||= []) << property_name - (@defaults ||= {})[property_name] = options.delete(:default) + (@@properties ||= []) << property_name + (@@defaults ||= {})[property_name] = options.delete(:default) class_eval <<-RUBY def #{property_name} @@ -43,7 +43,7 @@ module Hashie # Get a String array of the currently defined # properties on this Dash. def self.properties - @properties.collect{|p| p.to_s} + @@properties.collect{|p| p.to_s} end # Check to see if the specified property has already been @@ -54,7 +54,7 @@ module Hashie # The default values that have been set for this Dash def self.defaults - @defaults + @@defaults end # You may initialize a Dash with an attributes hash diff --git a/spec/hashie/dash_spec.rb b/spec/hashie/dash_spec.rb index 9443ef6..df27fe7 100644 --- a/spec/hashie/dash_spec.rb +++ b/spec/hashie/dash_spec.rb @@ -6,6 +6,9 @@ class DashTest < Hashie::Dash property :count, :default => 0 end +class Subclassed < DashTest +end + describe Hashie::Dash do it 'should be a subclass of Hashie::Hash' do (Hashie::Dash < Hash).should be_true @@ -77,4 +80,14 @@ describe Hashie::Dash do DashTest.new.defaulted.should == 'abc' end end +end + +describe Subclassed do + it "should inherit all properties from DashTest" do + Subclassed.properties.size.should == 5 + end + + it "should init without raising" do + lambda { Subclassed.new }.should_not raise_error + end end
\ No newline at end of file |