Class: ActionAdmin::ShortcodePresenter

Inherits:
Object
  • Object
show all
Includes:
Presentable
Defined in:
app/presenters/action_admin/shortcode_presenter.rb

Instance Method Summary collapse

Constructor Details

#initialize(shortcode, context) ⇒ ShortcodePresenter

Returns a new instance of ShortcodePresenter.



5
6
7
8
# File 'app/presenters/action_admin/shortcode_presenter.rb', line 5

def initialize(shortcode, context)
  @shortcode = shortcode
  @context   = context
end

Instance Method Details

#fieldsObject



10
11
12
# File 'app/presenters/action_admin/shortcode_presenter.rb', line 10

def fields
  self.record_fields
end

#render_field(form, field, options = {}) ⇒ Object



14
15
16
17
18
19
20
21
22
23
24
# File 'app/presenters/action_admin/shortcode_presenter.rb', line 14

def render_field(form, field, options={})
  options = Hash(options)

  options[:input_html]        ||= {}
  options[:input_html][:data] ||= {}

  options[:input_html][:data][:attribute] = field
  options[:input_html][:include_hidden]   = false

  form.input field, options
end

#render_fields(form) ⇒ Object



26
27
28
# File 'app/presenters/action_admin/shortcode_presenter.rb', line 26

def render_fields(form)
  fields.map { |f, o| render_field(form, f, o) }.join.html_safe
end