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 = {})
259259 return nil if object . nil?
260260 opts = options . merge ( runtime_options || { } )
261261 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 )
263263 partial_output = value_for ( attribute , opts )
264264 output [ key_for ( attribute ) ] =
265265 if partial_output . respond_to? :serializable_hash
Original file line number Diff line number Diff line change 253253
254254 describe '#serializable_hash' do
255255
256-
257-
258256 it 'should not throw an exception if a nil options object is passed' do
259257 expect { fresh_class . new ( model ) . serializable_hash ( nil ) } . not_to raise_error
260258 end
296294 res = fresh_class . new ( model ) . serializable_hash
297295 res . should have_key :non_existant_attribute
298296 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
299305
300306 context "#serializable_hash" do
301307
You can’t perform that action at this time.
0 commit comments