class BrainDamage::View::Input::PolymorphicSelect

Public Class Methods

new(field, options) click to toggle source
# File lib/generators/brain_damage/lib/views/inputs/polymorphic_select.rb, line 8
def initialize(field, options)
  super
  @normalized_name = name.to_s.gsub('_id', '').gsub('_type', '')
end

Public Instance Methods

object_select_name() click to toggle source
# File lib/generators/brain_damage/lib/views/inputs/polymorphic_select.rb, line 17
def object_select_name
  "#{@normalized_name}_id"
end
options_for_type() click to toggle source
# File lib/generators/brain_damage/lib/views/inputs/polymorphic_select.rb, line 21
def options_for_type
  @options[:options].map{ |option|
    "[cet('entities.#{option[:model].to_s.downcase}'), '#{option[:model].to_s}']"
  }.join ', '
end
type_select_name() click to toggle source
# File lib/generators/brain_damage/lib/views/inputs/polymorphic_select.rb, line 13
def type_select_name
  "#{@normalized_name}_type"
end
types_options() click to toggle source
# File lib/generators/brain_damage/lib/views/inputs/polymorphic_select.rb, line 27
def types_options
  @options[:options]
end