Class: Abyme::AbymeBuilder
- Inherits:
-
ActionView::Base
- Object
- ActionView::Base
- Abyme::AbymeBuilder
- Includes:
- ActionView
- Defined in:
- lib/abyme/abyme_builder.rb
Instance Method Summary collapse
-
#initialize(association:, form:, context:, partial:, locals:) {|_self| ... } ⇒ AbymeBuilder
constructor
If a block is given to the #abymize helper it will instanciate a new AbymeBuilder and pass to it the association name (Symbol) the form object, lookup_context optionaly a partial path then yield itself to the block.
-
#new_records(options = {}, &block) ⇒ Object
calls the #new_records_for helper method passing association, form and options to it.
-
#records(options = {}) ⇒ Object
calls the #persisted_records_for helper method passing association, form and options to it.
Constructor Details
#initialize(association:, form:, context:, partial:, locals:) {|_self| ... } ⇒ AbymeBuilder
If a block is given to the #abymize helper it will instanciate a new AbymeBuilder and pass to it the association name (Symbol) the form object, lookup_context optionaly a partial path then yield itself to the block
11 12 13 14 15 16 17 18 19 |
# File 'lib/abyme/abyme_builder.rb', line 11 def initialize(association:, form:, context:, partial:, locals:, &block) @association = association @form = form @context = context @lookup_context = context.lookup_context @partial = partial @locals = locals || {} yield(self) if block end |
Instance Method Details
#new_records(options = {}, &block) ⇒ Object
calls the #new_records_for helper method passing association, form and options to it
37 38 39 40 41 42 |
# File 'lib/abyme/abyme_builder.rb', line 37 def new_records( = {}, &block) locals = merge_locals([:locals]) new_records_for(@association, @form, ) do |fields_for_association| render_association_partial(@association, fields_for_association, @partial, locals, @context) end end |
#records(options = {}) ⇒ Object
calls the #persisted_records_for helper method passing association, form and options to it
26 27 28 29 30 31 |
# File 'lib/abyme/abyme_builder.rb', line 26 def records( = {}) locals = merge_locals([:locals]) persisted_records_for(@association, @form, ) do |fields_for_association| render_association_partial(@association, fields_for_association, @partial, locals, @context) end end |