Class: PluckMap::Presenter
- Inherits:
-
Object
- Object
- PluckMap::Presenter
- Includes:
- CsvPresenter, HashPresenter, JsonPresenter
- Defined in:
- lib/pluck_map/presenter.rb
Instance Attribute Summary collapse
-
#attributes ⇒ Object
readonly
Returns the value of attribute attributes.
-
#model ⇒ Object
readonly
Returns the value of attribute model.
Instance Method Summary collapse
-
#initialize(model = nil, attributes = nil, &block) ⇒ Presenter
constructor
A new instance of Presenter.
- #no_map? ⇒ Boolean
Methods included from CsvPresenter
Methods included from HashPresenter
Methods included from JsonPresenter
Constructor Details
#initialize(model = nil, attributes = nil, &block) ⇒ Presenter
Returns a new instance of Presenter.
11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 |
# File 'lib/pluck_map/presenter.rb', line 11 def initialize(model = nil, attributes = nil, &block) if block_given? puts "DEPRECATION WARNING: `PluckMap::Presenter.new` will be deprecated. Use `PluckMap[Model].define` instead." @attributes = PluckMap::AttributeBuilder.build(model: nil, &block) else @model = model @attributes = attributes end if respond_to?(:define_presenters!, true) puts "DEPRECATION WARNING: `define_presenters!` is deprecated; instead mix in a module that implements your presenter method (e.g. `to_h`). Optionally have the method redefine itself the first time it is called." # because overridden `define_presenters!` will probably call `super` PluckMap::Presenter.class_eval 'protected def define_presenters!; end' define_presenters! end end |
Instance Attribute Details
#attributes ⇒ Object (readonly)
Returns the value of attribute attributes.
9 10 11 |
# File 'lib/pluck_map/presenter.rb', line 9 def attributes @attributes end |
#model ⇒ Object (readonly)
Returns the value of attribute model.
9 10 11 |
# File 'lib/pluck_map/presenter.rb', line 9 def model @model end |
Instance Method Details
#no_map? ⇒ Boolean
28 29 30 31 |
# File 'lib/pluck_map/presenter.rb', line 28 def no_map? puts "DEPRECATION WARNING: `PluckMap::Presenter#no_map?` is deprecated. You can replace it with `!attributes.will_map?`" !attributes.will_map? end |