Class: RubySerializer::Base

Inherits:
Object
  • Object
show all
Extended by:
Dsl
Defined in:
lib/ruby_serializer/base.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods included from Dsl

belongs_to, expose, fields, has_many, has_one, serializes

Constructor Details

#initialize(resource) ⇒ Base

Returns a new instance of Base.



8
9
10
# File 'lib/ruby_serializer/base.rb', line 8

def initialize(resource)
  @resource = resource
end

Instance Attribute Details

#optionsObject (readonly)

Returns the value of attribute options.



6
7
8
# File 'lib/ruby_serializer/base.rb', line 6

def options
  @options
end

Instance Method Details

#as_json(options = {}) ⇒ Object



12
13
14
15
16
# File 'lib/ruby_serializer/base.rb', line 12

def as_json(options = {})
  json = serialize(options)
  json = { options[:root] => json } if options[:root]
  json
end