Class: Thorwald::Exporter

Inherits:
Object
  • Object
show all
Includes:
SafeAttributeAssignment
Defined in:
lib/thorwald/exporter.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(clazz, params, options = {}) ⇒ Exporter

Returns a new instance of Exporter.



9
10
11
12
13
14
15
16
17
18
19
# File 'lib/thorwald/exporter.rb', line 9

def initialize(clazz, params, options = {})
  @clazz = clazz
  @params = params

  options = {
    includes: [],
    attribute: :id
  }.merge(options)

  assign_attributes(options)
end

Instance Attribute Details

#attribute=(value) ⇒ Object

Sets the attribute attribute

Parameters:

  • value

    the value to set the attribute attribute to.



7
8
9
# File 'lib/thorwald/exporter.rb', line 7

def attribute=(value)
  @attribute = value
end

#clazzObject (readonly)

Returns the value of attribute clazz.



6
7
8
# File 'lib/thorwald/exporter.rb', line 6

def clazz
  @clazz
end

#includesObject

Returns the value of attribute includes.



7
8
9
# File 'lib/thorwald/exporter.rb', line 7

def includes
  @includes
end

#paramsObject (readonly)

Returns the value of attribute params.



6
7
8
# File 'lib/thorwald/exporter.rb', line 6

def params
  @params
end

#type=(value) ⇒ Object

Sets the attribute type

Parameters:

  • value

    the value to set the attribute type to.



7
8
9
# File 'lib/thorwald/exporter.rb', line 7

def type=(value)
  @type = value
end

Instance Method Details

#as_json(*args) ⇒ Object



21
22
23
# File 'lib/thorwald/exporter.rb', line 21

def as_json(*args) 
  export.as_json(include: includes)
end