Class: PluckMap::Presenter

Inherits:
Object
  • Object
show all
Includes:
CsvPresenter, HashPresenter, JsonPresenter
Defined in:
lib/pluck_map/presenter.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods included from CsvPresenter

included, #to_csv

Methods included from HashPresenter

included, #to_h

Methods included from JsonPresenter

included, #to_json

Constructor Details

#initialize(model, attributes, query) ⇒ Presenter

Returns a new instance of Presenter.



14
15
16
17
18
19
20
21
22
# File 'lib/pluck_map/presenter.rb', line 14

def initialize(model, attributes, query)
  unless query.model <= model
    raise ArgumentError, "Query for #{query.model} but #{model} expected"
  end

  @model = model
  @attributes = attributes
  @query = query
end

Instance Attribute Details

#attributesObject (readonly)

Returns the value of attribute attributes.



12
13
14
# File 'lib/pluck_map/presenter.rb', line 12

def attributes
  @attributes
end

#modelObject (readonly)

Returns the value of attribute model.



12
13
14
# File 'lib/pluck_map/presenter.rb', line 12

def model
  @model
end

#queryObject (readonly)

Returns the value of attribute query.



12
13
14
# File 'lib/pluck_map/presenter.rb', line 12

def query
  @query
end