File tree Expand file tree Collapse file tree 2 files changed +9
-3
lines changed Expand file tree Collapse file tree 2 files changed +9
-3
lines changed Original file line number Diff line number Diff line change @@ -259,7 +259,7 @@ def serializable_hash(runtime_options = {})
259
259
return nil if object . nil?
260
260
opts = options . merge ( runtime_options || { } )
261
261
exposures . inject ( { } ) do |output , ( attribute , exposure_options ) |
262
- if exposure_options . has_key? ( :proc ) || object . respond_to? ( attribute ) && conditions_met? ( exposure_options , opts )
262
+ if ( exposure_options . has_key? ( :proc ) || object . respond_to? ( attribute ) ) && conditions_met? ( exposure_options , opts )
263
263
partial_output = value_for ( attribute , opts )
264
264
output [ key_for ( attribute ) ] =
265
265
if partial_output . respond_to? :serializable_hash
Original file line number Diff line number Diff line change 253
253
254
254
describe '#serializable_hash' do
255
255
256
-
257
-
258
256
it 'should not throw an exception if a nil options object is passed' do
259
257
expect { fresh_class . new ( model ) . serializable_hash ( nil ) } . not_to raise_error
260
258
end
296
294
res = fresh_class . new ( model ) . serializable_hash
297
295
res . should have_key :non_existant_attribute
298
296
end
297
+
298
+ it "should not expose attributes that are generated by a block but have not passed criteria" do
299
+ fresh_class . expose :non_existant_attribute , :proc => lambda { |model , options |
300
+ "I exist, but it is not yet my time to shine"
301
+ } , :if => lambda { |model , options | false }
302
+ res = fresh_class . new ( model ) . serializable_hash
303
+ res . should_not have_key :non_existant_attribute
304
+ end
299
305
300
306
context "#serializable_hash" do
301
307
You can’t perform that action at this time.
0 commit comments