Class: ViewPartialFormBuilder::TemplateProxy
- Inherits:
-
Object
- Object
- ViewPartialFormBuilder::TemplateProxy
- Defined in:
- lib/view_partial_form_builder/template_proxy.rb
Instance Method Summary collapse
- #button_tag(value, options, &block) ⇒ Object
-
#initialize(builder:, template:) ⇒ TemplateProxy
constructor
A new instance of TemplateProxy.
- #label(object_name, method, content_or_options = nil, options = nil, &block) ⇒ Object
- #submit_tag(value, options) ⇒ Object
Constructor Details
#initialize(builder:, template:) ⇒ TemplateProxy
Returns a new instance of TemplateProxy.
5 6 7 8 |
# File 'lib/view_partial_form_builder/template_proxy.rb', line 5 def initialize(builder:, template:) @template = template @builder = builder end |
Dynamic Method Handling
This class handles dynamic methods through the method_missing method
#method_missing(name, *arguments, &block) ⇒ Object (private)
37 38 39 40 41 42 43 44 45 46 47 48 49 |
# File 'lib/view_partial_form_builder/template_proxy.rb', line 37 def method_missing(name, *arguments, &block) if @builder.respond_to?(name) arguments_after_object_name = arguments.from(1) render(name, arguments: arguments_after_object_name, block: block) do @template.public_send(name, *arguments, &block) end elsif @template.respond_to?(name) @template.public_send(name, *arguments, &block) else super end end |
Instance Method Details
#button_tag(value, options, &block) ⇒ Object
10 11 12 13 14 |
# File 'lib/view_partial_form_builder/template_proxy.rb', line 10 def (value, , &block) render(:button, arguments: [value, ], block: block) do @template.(value, , &block) end end |
#label(object_name, method, content_or_options = nil, options = nil, &block) ⇒ Object
22 23 24 25 26 27 28 29 30 31 32 33 |
# File 'lib/view_partial_form_builder/template_proxy.rb', line 22 def label(object_name, method, = nil, = nil, &block) if .is_a?(Hash) .merge! content = nil else content = end render(:label, arguments: [method, content, ], block: block) do @template.label(object_name, method, content, , &block) end end |
#submit_tag(value, options) ⇒ Object
16 17 18 19 20 |
# File 'lib/view_partial_form_builder/template_proxy.rb', line 16 def submit_tag(value, ) render(:submit, arguments: [value, ]) do @template.submit_tag(value, ) end end |