Class: Abyme::AbymeBuilder

Inherits:
ActionView::Base
  • Object
show all
Includes:
ActionView
Defined in:
lib/abyme/abyme_builder.rb

Instance Method Summary collapse

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

Yields:

  • (_self)

Yield Parameters:



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(options = {}, &block)
  locals = merge_locals(options[:locals])
  new_records_for(@association, @form, options) 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(options = {})
  locals = merge_locals(options[:locals])
  persisted_records_for(@association, @form, options) do |fields_for_association|
    render_association_partial(@association, fields_for_association, @partial, locals, @context)
  end
end