Class: Vodka::Server::VodkaPresenter
- Inherits:
-
Object
- Object
- Vodka::Server::VodkaPresenter
- Defined in:
- lib/vodka/server/presenters/vodka_presenter.rb
Instance Attribute Summary collapse
-
#resource ⇒ Object
Returns the value of attribute resource.
Instance Method Summary collapse
-
#initialize(resource) ⇒ VodkaPresenter
constructor
A new instance of VodkaPresenter.
- #json(hash) ⇒ Object
- #present ⇒ Object
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
#resource ⇒ Object
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. hash[:metadata] = {} hash end |
#present ⇒ Object
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 |