Class: FactoryBurgers::Presenters::Base
- Inherits:
-
Object
- Object
- FactoryBurgers::Presenters::Base
- Defined in:
- lib/factory_burgers/presenters/base.rb
Overview
Presenter classes are responsible for formatting application object data for the UI. This defatul presenter will display the id and name attributes, if they exist, and does not have an application link. Create subclasses of this class to present different information for different application models.
Instance Attribute Summary collapse
-
#object ⇒ Object
readonly
Returns the value of attribute object.
Class Method Summary collapse
Instance Method Summary collapse
- #attributes ⇒ Object
-
#initialize(object) ⇒ Base
constructor
A new instance of Base.
- #link_path ⇒ Object
- #type ⇒ Object
Constructor Details
#initialize(object) ⇒ Base
Returns a new instance of Base.
16 17 18 |
# File 'lib/factory_burgers/presenters/base.rb', line 16 def initialize(object) @object = object end |
Instance Attribute Details
#object ⇒ Object (readonly)
Returns the value of attribute object.
14 15 16 |
# File 'lib/factory_burgers/presenters/base.rb', line 14 def object @object end |
Class Method Details
.presents(name) ⇒ Object
9 10 11 |
# File 'lib/factory_burgers/presenters/base.rb', line 9 def presents(name) define_method(name) { object } end |
Instance Method Details
#attributes ⇒ Object
24 25 26 |
# File 'lib/factory_burgers/presenters/base.rb', line 24 def attributes object.attributes.slice("id", "name") end |
#link_path ⇒ Object
28 29 30 |
# File 'lib/factory_burgers/presenters/base.rb', line 28 def link_path nil end |
#type ⇒ Object
20 21 22 |
# File 'lib/factory_burgers/presenters/base.rb', line 20 def type object.class.name end |