Class: Vodka::Server::VodkaPresenter

Inherits:
Object
  • Object
show all
Defined in:
lib/vodka/server/presenters/vodka_presenter.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(resource) ⇒ VodkaPresenter

Returns a new instance of VodkaPresenter.



6
7
8
# File 'lib/vodka/server/presenters/vodka_presenter.rb', line 6

def initialize(resource)
  @resource = resource
end

Instance Attribute Details

#resourceObject

Returns the value of attribute resource.



4
5
6
# File 'lib/vodka/server/presenters/vodka_presenter.rb', line 4

def resource
  @resource
end

Instance Method Details

#json(hash) ⇒ Object



14
15
16
17
18
# File 'lib/vodka/server/presenters/vodka_presenter.rb', line 14

def json(hash)
  hash[:errors] = resource.errors.messages
  hash[:metadata] = {}
  hash
end

#presentObject

Raises:

  • (::Exception)


10
11
12
# File 'lib/vodka/server/presenters/vodka_presenter.rb', line 10

def present
  raise ::Exception.new("#{self.class.name}#present must be defined!")
end