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:) {|_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
# File 'lib/abyme/abyme_builder.rb', line 11

def initialize(association:, form:, context:, partial:, &block)
  @association = association
  @form = form
  @context = context
  @lookup_context = context.lookup_context
  @partial = partial
  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



35
36
37
38
39
# File 'lib/abyme/abyme_builder.rb', line 35

def new_records(options = {}, &block)
  new_records_for(@association, @form, options) do |fields_for_association|
    render_association_partial(@association, fields_for_association, @partial, @context)
  end
end

#records(options = {}) ⇒ Object

calls the #persisted_records_for helper method passing association, form and options to it



25
26
27
28
29
# File 'lib/abyme/abyme_builder.rb', line 25

def records(options = {})
  persisted_records_for(@association, @form, options) do |fields_for_association|
    render_association_partial(@association, fields_for_association, @partial, @context)
  end
end