Class: PluckMap::Presenter
- Inherits:
-
Object
- Object
- PluckMap::Presenter
- Includes:
- HashPresenter
- Defined in:
- lib/pluck_map/presenter.rb
Instance Attribute Summary collapse
-
#attributes ⇒ Object
readonly
Returns the value of attribute attributes.
Instance Method Summary collapse
-
#initialize(&block) ⇒ Presenter
constructor
A new instance of Presenter.
- #no_map? ⇒ Boolean
Methods included from HashPresenter
Constructor Details
#initialize(&block) ⇒ Presenter
Returns a new instance of Presenter.
10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 |
# File 'lib/pluck_map/presenter.rb', line 10 def initialize(&block) @attributes = PluckMap::AttributeBuilder.build(&block) @attributes_by_id = {} @selects = [] attributes.each do |attribute| attribute.indexes = attribute.selects.map do |select| selects.find_index(select) || begin selects.push(select) selects.length - 1 end end attributes_by_id[attribute.id] = attribute 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.
8 9 10 |
# File 'lib/pluck_map/presenter.rb', line 8 def attributes @attributes end |
Instance Method Details
#no_map? ⇒ Boolean
33 34 35 |
# File 'lib/pluck_map/presenter.rb', line 33 def no_map? attributes.all?(&:no_map?) end |