defined_hash 0.1.1 → 0.2.0

Sign up to get free protection for your applications and to get access to all the features.
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.1.1
1
+ 0.2.0
@@ -143,6 +143,11 @@ class DefinedHash < Hash
143
143
  out
144
144
  end
145
145
 
146
+ def self.inherited(subclass)
147
+ subclass.instance_variable_set('@properties', self.instance_variable_get('@properties').dup) unless self.instance_variable_get('@properties').nil?
148
+ subclass.instance_variable_set('@validations', self.instance_variable_get('@validations').dup) unless self.instance_variable_get('@validations').nil?
149
+ end
150
+
146
151
 
147
152
  private
148
153
  def self.class_validator_for(type)
@@ -198,4 +198,21 @@ BareTest.suite "DefinedHash" do
198
198
  @person == Person.new(:name => 'name', :page => 'page')
199
199
  end
200
200
  end
201
+
202
+ suite "subclassing" do
203
+ setup do
204
+ class ::Programmer < Person
205
+ property :fav_language, String
206
+ end
207
+ end
208
+ teardown do
209
+ Object.send(:remove_const, :Programmer)
210
+ end
211
+ assert "properties list is correct" do
212
+ equal({:name => String, :page => String, :fav_language => String}, Programmer.properties)
213
+ end
214
+ assert "validations are inherited" do
215
+ Programmer.new(:fav_language => 'ruby').valid? == false
216
+ end
217
+ end
201
218
  end
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: defined_hash
3
3
  version: !ruby/object:Gem::Version
4
- hash: 25
4
+ hash: 23
5
5
  prerelease: false
6
6
  segments:
7
7
  - 0
8
- - 1
9
- - 1
10
- version: 0.1.1
8
+ - 2
9
+ - 0
10
+ version: 0.2.0
11
11
  platform: ruby
12
12
  authors:
13
13
  - Jonathan Stott
@@ -15,7 +15,7 @@ autorequire:
15
15
  bindir: bin
16
16
  cert_chain: []
17
17
 
18
- date: 2010-07-25 00:00:00 +01:00
18
+ date: 2010-08-09 00:00:00 +01:00
19
19
  default_executable:
20
20
  dependencies:
21
21
  - !ruby/object:Gem::Dependency