File tree Expand file tree Collapse file tree 2 files changed +12
-1
lines changed
Expand file tree Collapse file tree 2 files changed +12
-1
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 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 252252 subject { fresh_class . new ( model ) }
253253
254254 describe '#serializable_hash' do
255+
256+
257+
255258 it 'should not throw an exception if a nil options object is passed' do
256259 expect { fresh_class . new ( model ) . serializable_hash ( nil ) } . not_to raise_error
257260 end
285288 res . should_not have_key :non_existant_attribute
286289 res . should_not have_key :non_existant_attribute2
287290 end
291+
292+ it "should expose attributes that don't exist on the object only when they are generated by a block" do
293+ fresh_class . expose :non_existant_attribute do |model , options |
294+ "well, I do exist after all"
295+ end
296+ res = fresh_class . new ( model ) . serializable_hash
297+ res . should have_key :non_existant_attribute
298+ end
288299
289300 context "#serializable_hash" do
290301
You can’t perform that action at this time.
0 commit comments