Class: BrainDamage::View::Input::AutocompletableMultipleSelection

Inherits:
Autocompletable show all
Defined in:
lib/generators/brain_damage/lib/views/inputs/autocompletable_multiple_selection.rb

Instance Attribute Summary

Attributes inherited from Templateable::FieldTemplateable

#partial_html, #type

Attributes inherited from Templateable::Base

#inner_html, #options, #template_file

Instance Method Summary collapse

Methods inherited from Autocompletable

#display_method, #target, #url, #value_method

Methods inherited from Base

#dir, #tag_options

Methods inherited from Templateable::FieldTemplateable

#empty_haml_path, #initialize, #label_guard?, #method_missing, #render, #show?, #show_label?

Methods inherited from Templateable::Base

#indent, #initialize, #method_missing, #render, #render_erb_file, #render_erb_string, #render_template_file

Constructor Details

This class inherits a constructor from BrainDamage::Templateable::FieldTemplateable

Dynamic Method Handling

This class handles dynamic methods through the method_missing method in the class BrainDamage::Templateable::FieldTemplateable

Instance Method Details

#input_nameObject



19
20
21
# File 'lib/generators/brain_damage/lib/views/inputs/autocompletable_multiple_selection.rb', line 19

def input_name
  @options[:input_name] || render_erb_string("<%= singular_table_name %>[<%= name.to_s.singularize %>_ids][]")
end

#partial_to_showObject



15
16
17
# File 'lib/generators/brain_damage/lib/views/inputs/autocompletable_multiple_selection.rb', line 15

def partial_to_show
  @options[:partial_to_show] || "#{target}/autocompletable/multiple_selection"
end

#valueObject



11
12
13
# File 'lib/generators/brain_damage/lib/views/inputs/autocompletable_multiple_selection.rb', line 11

def value
  "#{singular_table_name}.#{name}.map { |item| { display: item.#{display_method}, value: item.#{value_method} }}.to_json"
end

#valuesObject



7
8
9
# File 'lib/generators/brain_damage/lib/views/inputs/autocompletable_multiple_selection.rb', line 7

def values
  "if #{singular_table_name}.#{name}.any? then #{value} else 'null' end"
end