Class: ActiveModel::DefaultSerializer

Inherits:
Object
  • Object
show all
Defined in:
lib/active_model/serializer.rb

Overview

DefaultSerializer

Provides a constant interface for all items, particularly for ArraySerializer.

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(object, options = {}) ⇒ DefaultSerializer

Returns a new instance of DefaultSerializer.



507
508
509
# File 'lib/active_model/serializer.rb', line 507

def initialize(object, options={})
  @object, @options = object, options
end

Instance Attribute Details

#objectObject (readonly)

Returns the value of attribute object.



505
506
507
# File 'lib/active_model/serializer.rb', line 505

def object
  @object
end

#optionsObject (readonly)

Returns the value of attribute options.



505
506
507
# File 'lib/active_model/serializer.rb', line 505

def options
  @options
end

Instance Method Details

#serializable_hashObject



511
512
513
# File 'lib/active_model/serializer.rb', line 511

def serializable_hash
  @object.as_json(@options)
end