Class: TypeStation::Presenter
- Inherits:
-
BasePresenter
- Object
- BasePresenter
- TypeStation::Presenter
- Defined in:
- app/presenters/type_station/presenter.rb
Direct Known Subclasses
Class Attribute Summary collapse
-
.form_fields ⇒ Object
Returns the value of attribute form_fields.
Class Method Summary collapse
Instance Method Summary collapse
- #create(type, user_options = {}, &block) ⇒ Object
- #delete(user_options = {}, &block) ⇒ Object
- #edit(user_options = {}, &block) ⇒ Object
- #field(name, user_options = {}, &block) ⇒ Object
- #move(direction, user_options = {}, &block) ⇒ Object
Methods inherited from BasePresenter
Constructor Details
This class inherits a constructor from TypeStation::BasePresenter
Dynamic Method Handling
This class handles dynamic methods through the method_missing method in the class TypeStation::BasePresenter
Class Attribute Details
.form_fields ⇒ Object
Returns the value of attribute form_fields.
7 8 9 |
# File 'app/presenters/type_station/presenter.rb', line 7 def form_fields @form_fields end |
Class Method Details
.form_field(name, options) ⇒ Object
9 10 11 12 |
# File 'app/presenters/type_station/presenter.rb', line 9 def form_field(name, ) @form_fields ||= [] @form_fields << {name: name, type: [:type].to_s, label: [:label], options: [:options], default: [:default], required: [:required]} end |
Instance Method Details
#create(type, user_options = {}, &block) ⇒ Object
15 16 17 18 |
# File 'app/presenters/type_station/presenter.rb', line 15 def create(type, = {}, &block) = { type: type == :page ? nil : type, model_parent_id: @object.to_param, action: :create }.merge() entity_block(h.capture(&block), ) end |
#delete(user_options = {}, &block) ⇒ Object
25 26 27 28 |
# File 'app/presenters/type_station/presenter.rb', line 25 def delete( = {}, &block) = { action: :delete }.merge() entity_block(h.capture(&block), ) end |
#edit(user_options = {}, &block) ⇒ Object
20 21 22 23 |
# File 'app/presenters/type_station/presenter.rb', line 20 def edit( = {}, &block) = { action: :edit, presenter: self.class }.merge() entity_block(h.capture(&block), ) end |
#field(name, user_options = {}, &block) ⇒ Object
35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 |
# File 'app/presenters/type_station/presenter.rb', line 35 def field(name, = {}, &block) content = '' = { type: :text, field: name, url: h.type_station.admin_entity_url(@object) }.merge() content_attribute = @object.get name if content_attribute.present? content_presenter = ContentPresenter.new(content_attribute, h, ) if content_presenter.value_is_hash? content += h.capture(content_presenter, &block) else content += content_presenter.value end else content += h.capture(ContentPresenter.new(nil,h, ), &block) end TypeStation::Blocks::Field.new(h., @object, ).render(content) end |
#move(direction, user_options = {}, &block) ⇒ Object
30 31 32 33 |
# File 'app/presenters/type_station/presenter.rb', line 30 def move(direction, = {}, &block) = { action: :move, options: { direction: "move_#{direction}"} }.merge() entity_block(h.capture(&block), ) end |