Skip to content

Commit

Permalink
Merge f969144 into 8ca4d4f
Browse files Browse the repository at this point in the history
  • Loading branch information
TimPetricola committed Mar 10, 2014
2 parents 8ca4d4f + f969144 commit 7a93a3d
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 1 deletion.
3 changes: 2 additions & 1 deletion lib/active_model/serializer.rb
Original file line number Diff line number Diff line change
Expand Up @@ -108,8 +108,9 @@ def initialize(object, options={})
@meta_key = options[:meta_key] || :meta
@meta = options[@meta_key]
@wrap_in_array = options[:_wrap_in_array]
@context = options[:context]
end
attr_accessor :object, :scope, :root, :meta_key, :meta
attr_accessor :object, :scope, :root, :meta_key, :meta, :context

def json_key
if root == true || root.nil?
Expand Down
15 changes: 15 additions & 0 deletions test/unit/active_model/serializer/options_test.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
require 'test_helper'

module ActiveModel
class Serializer
class OptionsTest < Minitest::Test
def setup
@serializer = ProfileSerializer.new(nil, context: {foo: :bar})
end

def test_custom_options_are_accessible_from_serializer
assert_equal({foo: :bar}, @serializer.context)
end
end
end
end

0 comments on commit 7a93a3d

Please sign in to comment.