Class: Admin::PostBuilder
- Inherits:
-
ActionView::Helpers::FormBuilder
- Object
- ActionView::Helpers::FormBuilder
- Admin::PostBuilder
- Defined in:
- lib/ecrire/app/forms/admin/post_builder.rb
Instance Method Summary collapse
- #action ⇒ Object
- #editor ⇒ Object
- #errors ⇒ Object
-
#initialize(object_name, object, template, options) ⇒ PostBuilder
constructor
A new instance of PostBuilder.
- #method_missing(method, *args, &block) ⇒ Object
- #t(*args) ⇒ Object
Constructor Details
#initialize(object_name, object, template, options) ⇒ PostBuilder
Returns a new instance of PostBuilder.
4 5 6 7 8 9 |
# File 'lib/ecrire/app/forms/admin/post_builder.rb', line 4 def initialize(object_name, object, template, ) if object.draft? [:html][:class] << 'autosave' end super end |
Dynamic Method Handling
This class handles dynamic methods through the method_missing method
#method_missing(method, *args, &block) ⇒ Object
43 44 45 |
# File 'lib/ecrire/app/forms/admin/post_builder.rb', line 43 def method_missing(method, *args, &block) @template.send(method, *args, &block) end |
Instance Method Details
#action ⇒ Object
31 32 33 34 35 36 37 |
# File 'lib/ecrire/app/forms/admin/post_builder.rb', line 31 def action if object.published? 'Save', value: 'save', form: "postEditor" else 'Publish', value: 'publish', form: "postEditor" end end |
#editor ⇒ Object
21 22 23 24 25 26 27 28 29 |
# File 'lib/ecrire/app/forms/admin/post_builder.rb', line 21 def editor content_tag :section, class: %w(textareas) do [ text_area(:content, placeholder: t('.content'), class: %w(content active), target: 'content'), text_area(:stylesheet, placeholder: t('.stylesheet'), class: %w(stylesheet), target: 'stylesheet'), text_area(:javascript, placeholder: t('.javascript'), class: %w(javascript), target: 'javascript') ].join.html_safe end end |
#errors ⇒ Object
11 12 13 14 15 16 17 18 19 |
# File 'lib/ecrire/app/forms/admin/post_builder.rb', line 11 def errors return unless object.errors.any? content_tag :div, class: %w(container errors) do [ content_tag(:span, h(object.errors..to_sentence)), link_to("x", "javascript:void(0)", class: %w(dismiss button)) ].join.html_safe end end |
#t(*args) ⇒ Object
39 40 41 |
# File 'lib/ecrire/app/forms/admin/post_builder.rb', line 39 def t(*args) I18n.t args[0], scope: %w(admin form post) end |