son_jay 0.5.1 → 0.5.2

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.
checksums.yaml CHANGED
@@ -1,15 +1,15 @@
1
1
  ---
2
2
  !binary "U0hBMQ==":
3
3
  metadata.gz: !binary |-
4
- YjZlMzcyMGIwYjczZTY1NDc2MGY0NmRlZjRjNzgzYTg4YjIxYjg0Nw==
4
+ Y2JiYTQyYzQ2YTY0ZjE0ZGU2Y2Q2ZGU0M2QyMDcxNGFjZGExMDdjZA==
5
5
  data.tar.gz: !binary |-
6
- NmE4ZDU5ZGQwOGU5ZDFmYzVkNzViNmVlY2I5MDE5ZTg3NjViOGI2OQ==
6
+ YWQzMzA5YTlhNzdkYmQxYWExM2E0ZTRhZWVkNTQ3ZjgxMDcwY2EwZQ==
7
7
  SHA512:
8
8
  metadata.gz: !binary |-
9
- NzM3MDViMTVmNDgyNjg4MzY5M2RiYjBhMWJlZGZjOWU3MDJlZWI1YzZlNjZh
10
- ZjU5ZjM0YTQ0NWYwYWZmOTFlNDAwNzVkOGI0MDEwMzAzNmE3MzQ4OGJkOWFl
11
- ODg0YzE1OTVkZjNmNzY0YzY4NzI2ZTdkNzJkOTYxZDdjNTI4NmE=
9
+ M2JlNTE5NTRmOTVlZThkZGM2NDBiYTEzY2I5NmVhM2E0MWQxNTZkNmZjMzVh
10
+ NGNiM2NiNDA5YjFlOTg5ZDU3MmZkYjZlYjM3MTFjNDU4YTZmNjJhMzFhOTVk
11
+ OGEwNTk3ODJiNzVhMDRlZTRiMTM0NmQ0YzQ4ZWQwNDliOTYxNmY=
12
12
  data.tar.gz: !binary |-
13
- NmVlMDFkMTg2MDU5MDVjYjFhOGYxMTllMzIwMjE0M2MwOTMxYTJjOGQ1ZTc1
14
- MTFlN2Q4YzA5ZjBkMzE2MTU1MzNhNWM4MjI3MWZmZjc1NzFjZDA0NzAzMjk4
15
- MTMzZmQ1YTUxYjg5MjFiY2M4YjE5YmY4MzM0MzcwNjUxNDc2Nzk=
13
+ MjcxNTRkYjllYWI1M2Q3ZjNiMDVmYmQ1ZjE0ODlmOGEwOTFjN2FhOWRmNDU1
14
+ YWZhZWNjODE1ODQ3ODlkYjEyMzU1NWYyNDY4MmU3YzI0ZjE3M2EwODA5OWM5
15
+ MmZjMWQ2ZTBjZGUwOGZiM2FjMDQ4MTdmNGE2NmQ3NjhjZWM0MmM=
data/CHANGELOG.md CHANGED
@@ -1,3 +1,8 @@
1
+ ### 0.5.2
2
+ * Enhancements
3
+ * Subclasses can override declared object model methods and
4
+ can access the declarative behavior via super
5
+
1
6
  ### 0.5.1
2
7
  * Enhancements
3
8
  * Prettier #inspect output for instances of model classes
@@ -107,13 +107,23 @@ module SonJay
107
107
  def _apply_property_definitions(definitions)
108
108
  definitions.each do |d|
109
109
  name = d.name
110
- class_eval <<-CODE
110
+ property_defs_module.module_eval <<-CODE
111
111
  def #{name} ; model_content[#{name.inspect}] ; end
112
112
  def #{name}=(value) ; model_content[#{name.inspect}] = value ; end
113
113
  CODE
114
114
  end
115
115
  end
116
116
 
117
+ def property_defs_module
118
+ @property_defs_module ||= begin
119
+ Module.new.tap do |mod|
120
+ const_set :HasPropertyAccessors, mod
121
+ include mod
122
+ end
123
+ end
124
+ end
125
+
126
+
117
127
  def _validate_model_dependencies!(dependants=Set.new)
118
128
  raise InfiniteRegressError if dependants.include?(self)
119
129
  dependants << self
@@ -1,3 +1,3 @@
1
1
  module SonJay
2
- VERSION = "0.5.1"
2
+ VERSION = "0.5.2"
3
3
  end
@@ -153,6 +153,20 @@ describe SonJay::ObjectModel do
153
153
  expect( instance.detail_z.zzz ).to eq('z')
154
154
  end
155
155
 
156
+ it "allows declared methods to be overridden in subclasses" do
157
+ subclass = Class.new(model_class) do
158
+ def aaa=(value) ; super "<#{value}>" ; end
159
+ def bbb ; "[#{super}]" ; end
160
+ end
161
+ subinst = subclass.new
162
+
163
+ subinst.aaa = 'abc'
164
+ subinst.model_content['bbb'] = 'xyz'
165
+
166
+ expect( subinst.model_content['aaa'] ).to eq('<abc>')
167
+ expect( subinst.bbb ).to eq('[xyz]')
168
+ end
169
+
156
170
  context "with more properties added via an additional ::properies block" do
157
171
  before do
158
172
 
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: son_jay
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.5.1
4
+ version: 0.5.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Steve Jorgensen
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-05-16 00:00:00.000000000 Z
11
+ date: 2015-06-04 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler