diff --git a/lib/active_model/serializer/adapter/simple_adapter.rb b/lib/active_model/serializer/adapter/simple_adapter.rb index 02b244ae..da397896 100644 --- a/lib/active_model/serializer/adapter/simple_adapter.rb +++ b/lib/active_model/serializer/adapter/simple_adapter.rb @@ -2,10 +2,14 @@ module ActiveModel class Serializer class Adapter class SimpleAdapter < Adapter - def to_json(options={}) + def serializable_hash(options = {}) serializer.attributes.each_with_object({}) do |(attr, value), h| h[attr] = value - end.to_json # FIXME: why does passing options here cause {}? + end + end + + def to_json(options={}) + serializable_hash(options).to_json end end end diff --git a/test/adapter/simple_adapter_test.rb b/test/adapter/simple_adapter_test.rb index e0374026..5805184f 100644 --- a/test/adapter/simple_adapter_test.rb +++ b/test/adapter/simple_adapter_test.rb @@ -11,6 +11,10 @@ module ActiveModel @adapter = SimpleAdapter.new(@profile_serializer) end + def test_serializable_hash + assert_equal({name: 'Name 1', description: 'Description 1'}, @adapter.serializable_hash) + end + def test_simple_adapter assert_equal('{"name":"Name 1","description":"Description 1"}', @adapter.to_json)