Class: Basepack::Forms::List

Inherits:
Base
  • Object
show all
Defined in:
lib/basepack/forms/list.rb

Instance Attribute Summary collapse

Attributes inherited from Base

#association_chain, #factory, #groups, #nested_in, #resource, #resource_class, #view

Instance Method Summary collapse

Methods inherited from Base

#build_from_factory, #chain, #chain_with_class, #configure, #content_for_field, #default_group, #default_partial, #field, #field_names, #fields, #fields_hash, #group, #has_field?, #hide_field, #hide_fields, #inspect, #inverse_of_nested_in?, #label, #label_plural, #new_form, #new_record?, #path, #permit_params, #render_field, #render_field!, #sanitize_params, #show_fields, #show_only_fields, #translate, #visible_field, #visible_fields, #visible_groups, #with_resource

Constructor Details

#initialize(factory, chain, options = {}) ⇒ List

Returns a new instance of List.



6
7
8
9
# File 'lib/basepack/forms/list.rb', line 6

def initialize(factory, chain, options = {})
  super(factory, chain, options)
  @query_form = options[:query_form]
end

Instance Attribute Details

#query_formObject (readonly)

Returns the value of attribute query_form.



4
5
6
# File 'lib/basepack/forms/list.rb', line 4

def query_form
  @query_form
end

Instance Method Details

#collectionObject



21
22
23
# File 'lib/basepack/forms/list.rb', line 21

def collection
  @query_form ? @query_form.collection : []
end

#collection_each(&block) ⇒ Object



25
26
27
28
29
# File 'lib/basepack/forms/list.rb', line 25

def collection_each(&block)
  collection.each_with_index do |res, i|
    with_resource(res, res, i, &block)
  end
end

#collection_without_paginationObject



31
32
33
# File 'lib/basepack/forms/list.rb', line 31

def collection_without_pagination
  collection.offset(nil).limit(nil)
end

#partialObject



16
17
18
19
# File 'lib/basepack/forms/list.rb', line 16

def partial
  section = factory.section
  Basepack::Utils.model_config(resource_class).send(section).partial
end

#view=(view) ⇒ Object



11
12
13
14
# File 'lib/basepack/forms/list.rb', line 11

def view=(view)
  super
  @query_form.view = view if @query_form
end