Sha256: e0174dca75a2ddc1892f6e1f3d1e638e587b2102051dcfe9cfbbb5512a3a179f

Contents?: true

Size: 646 Bytes

Versions: 3

Compression:

Stored size: 646 Bytes

Contents

module Select2Concern
  extend ActiveSupport::Concern
  included do
    after_initialize do
      self.class.instance_methods.grep(/ids=$/) do |method_name|
        self.class.send(:define_method, method_name) do |value|
          value = value.split(',') if value.is_a? String
          super value
        end
      end
    end
  end

  module ClassMethods
    include Select2Helper::Errors

    def select2_white_list *names
      @select2_white_list = names
    end

    def select2_allowed_search? column_name
      raise InvalidColumnName unless attribute_method? column_name
      @select2_white_list.include? column_name
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
select2_helper-0.2.1 app/models/concerns/select2_concern.rb
select2_helper-0.2.0 app/models/concerns/select2_concern.rb
select2_helper-0.1.4 app/models/concerns/select2_concern.rb