domain_model 0.1.1 → 0.1.2

Sign up to get free protection for your applications and to get access to all the features.
data/.gitignore CHANGED
@@ -15,3 +15,4 @@ spec/reports
15
15
  test/tmp
16
16
  test/version_tmp
17
17
  tmp
18
+ vendor/
data/lib/domain_model.rb CHANGED
@@ -59,7 +59,9 @@ module DomainModel
59
59
  end
60
60
 
61
61
  def fields
62
- @fields ||= []
62
+ @fields ||= begin
63
+ superclass.include?(DomainModel) ? (superclass.fields.dup) : []
64
+ end
63
65
  end
64
66
 
65
67
  def validations
@@ -1,3 +1,3 @@
1
1
  module DomainModel
2
- VERSION = "0.1.1"
2
+ VERSION = "0.1.2"
3
3
  end
@@ -25,6 +25,17 @@ describe DomainModel do
25
25
 
26
26
  expect(&required_collection).to raise_error(ArgumentError, /fields cannot be both :collection and :required/ )
27
27
  end
28
+
29
+ it "inherits fields from superclasses" do
30
+ define { field :parent_field }
31
+
32
+ child_a = Class.new(Client) { field :child_a_field }
33
+ child_b = Class.new(Client) { field :child_b_field }
34
+
35
+ expect(Client.fields.map(&:name)).to eq([:parent_field])
36
+ expect(child_a.fields.map(&:name)).to eq([:parent_field, :child_a_field])
37
+ expect(child_b.fields.map(&:name)).to eq([:parent_field, :child_b_field])
38
+ end
28
39
  end
29
40
 
30
41
  describe ".validate" do
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: domain_model
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.1
4
+ version: 0.1.2
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2014-03-17 00:00:00.000000000 Z
12
+ date: 2014-03-18 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: bundler
@@ -74,7 +74,7 @@ files:
74
74
  - domain_model.gemspec
75
75
  - lib/domain_model.rb
76
76
  - lib/domain_model/version.rb
77
- - spec/model_spec.rb
77
+ - spec/domain_model_spec.rb
78
78
  - spec/spec_helper.rb
79
79
  homepage: ''
80
80
  licenses:
@@ -102,5 +102,5 @@ signing_key:
102
102
  specification_version: 3
103
103
  summary: Minimal framework for definition of type-aware domain models
104
104
  test_files:
105
- - spec/model_spec.rb
105
+ - spec/domain_model_spec.rb
106
106
  - spec/spec_helper.rb