praxis-blueprints 1.1.0 → 1.1.1
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 +4 -4
- data/CHANGELOG.md +1 -1
- data/lib/praxis-blueprints/blueprint.rb +16 -13
- data/lib/praxis-blueprints/version.rb +1 -1
- data/spec/praxis-blueprints/blueprint_spec.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 97b7352ecab8d56459df9325ca4950ef87f8ebb1
|
4
|
+
data.tar.gz: bde131b221dd5535017d22a7b54c592565a7d27c
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: a48ba08bf752647dec66aaf024d230d2e97ad26d157c5e0f2969ace71c23b2d3de14c27d8fd2aa694c717246b47b43b60ee971e0f4ef6102f880b5e636a4e781
|
7
|
+
data.tar.gz: 59ff0611ce4a0322f7bda51af02928a482bc556a4a2f1362a126ab59ddbdbc58612bf5014047ecd06c3821822154b91cd5ca3976f81972101bf09b7a2c384fc0
|
data/CHANGELOG.md
CHANGED
@@ -82,7 +82,7 @@ module Praxis
|
|
82
82
|
opts[:reference] = self
|
83
83
|
end
|
84
84
|
|
85
|
-
@options
|
85
|
+
@options.merge!(opts)
|
86
86
|
@block = block
|
87
87
|
end
|
88
88
|
|
@@ -274,21 +274,26 @@ module Praxis
|
|
274
274
|
else
|
275
275
|
value = @object.send(name)
|
276
276
|
return value if value.nil? || value.kind_of?(attribute.type)
|
277
|
-
attribute.type.
|
277
|
+
attribute.type.load(value)
|
278
278
|
end
|
279
279
|
end
|
280
280
|
end
|
281
281
|
|
282
282
|
def self.define_direct_reader!(name)
|
283
|
-
|
284
|
-
|
285
|
-
|
286
|
-
|
287
|
-
|
288
|
-
|
289
|
-
|
290
|
-
|
291
|
-
|
283
|
+
attribute = self.attributes[name]
|
284
|
+
# TODO: profile and optimize
|
285
|
+
# because we use the attribute in the reader,
|
286
|
+
# it's likely faster to use define_method here
|
287
|
+
# than module_eval, but we should make sure.
|
288
|
+
define_method(name) do
|
289
|
+
if @decorators && @decorators.respond_to?(name)
|
290
|
+
@decorators.send(name)
|
291
|
+
else
|
292
|
+
value = @object.__send__(name)
|
293
|
+
return value if value.nil? || value.kind_of?(attribute.type)
|
294
|
+
attribute.load(value)
|
295
|
+
end
|
296
|
+
end
|
292
297
|
end
|
293
298
|
|
294
299
|
def self.generate_master_view!
|
@@ -304,14 +309,12 @@ module Praxis
|
|
304
309
|
|
305
310
|
|
306
311
|
def validate(context=Attributor::DEFAULT_ROOT_CONTEXT)
|
307
|
-
|
308
312
|
raise ArgumentError, "Invalid context received (nil) while validating value of type #{self.name}" if context == nil
|
309
313
|
context = [context] if context.is_a? ::String
|
310
314
|
|
311
315
|
raise "validation conflict" if @validating
|
312
316
|
@validating = true
|
313
317
|
|
314
|
-
|
315
318
|
self.class.attributes.each_with_object(Array.new) do |(sub_attribute_name, sub_attribute), errors|
|
316
319
|
sub_context = self.class.generate_subcontext(context,sub_attribute_name)
|
317
320
|
value = self.send(sub_attribute_name)
|
@@ -309,7 +309,7 @@ describe Praxis::Blueprint do
|
|
309
309
|
person.address.should_receive(:state).and_raise("Kaboom")
|
310
310
|
expect {
|
311
311
|
person.render(view_name, context: ['special_root'])
|
312
|
-
}.to raise_error(/Error while dumping attribute state of type Address for context special_root.address
|
312
|
+
}.to raise_error(/Error while dumping attribute state of type Address for context special_root.address. Reason: .*Kaboom/)
|
313
313
|
end
|
314
314
|
end
|
315
315
|
|