Class: Webmate::BasePresenter
- Inherits:
-
Object
- Object
- Webmate::BasePresenter
- Includes:
- Presenters::Scoped
- Defined in:
- lib/webmate/presenters/base_presenter.rb
Instance Attribute Summary collapse
-
#accessor ⇒ Object
Returns the value of attribute accessor.
-
#resources ⇒ Object
Returns the value of attribute resources.
Instance Method Summary collapse
- #errors ⇒ Object
-
#initialize(resources) ⇒ BasePresenter
constructor
A new instance of BasePresenter.
- #to_json(options = {}) ⇒ Object
- #to_serializable ⇒ Object
Methods included from Presenters::Scoped
Constructor Details
#initialize(resources) ⇒ BasePresenter
Returns a new instance of BasePresenter.
7 8 9 10 11 |
# File 'lib/webmate/presenters/base_presenter.rb', line 7 def initialize(resources) raise ArgumentError, "Resources should not be blank" if resources.blank? @resources = resources @errors = [] end |
Instance Attribute Details
#accessor ⇒ Object
Returns the value of attribute accessor.
5 6 7 |
# File 'lib/webmate/presenters/base_presenter.rb', line 5 def accessor @accessor end |
#resources ⇒ Object
Returns the value of attribute resources.
5 6 7 |
# File 'lib/webmate/presenters/base_presenter.rb', line 5 def resources @resources end |
Instance Method Details
#errors ⇒ Object
19 20 21 |
# File 'lib/webmate/presenters/base_presenter.rb', line 19 def errors @errors end |
#to_json(options = {}) ⇒ Object
23 24 25 |
# File 'lib/webmate/presenters/base_presenter.rb', line 23 def to_json( = {}) serialize_resource.to_json end |
#to_serializable ⇒ Object
13 14 15 16 17 |
# File 'lib/webmate/presenters/base_presenter.rb', line 13 def to_serializable build_serialized default_resource do |object| attributes object.attributes.keys end end |