Class: Rails::AddOns::SearchFormHelper::SearchableCollection

Inherits:
Object
  • Object
show all
Extended by:
ActiveModel::Translation
Includes:
ActiveModel::Model
Defined in:
app/helpers/rails/add_ons/search_form_helper.rb

Instance Method Summary collapse

Methods included from ActiveModel::Model

included, #persisted?

Constructor Details

#initialize(collection, query) ⇒ SearchableCollection


74
75
76
77
# File 'app/helpers/rails/add_ons/search_form_helper.rb', line 74

def initialize(collection, query)
  @collection = collection
  @query = query || {}
end

Dynamic Method Handling

This class handles dynamic methods through the method_missing method

#method_missing(method, *args) ⇒ Object


66
67
68
69
70
71
72
# File 'app/helpers/rails/add_ons/search_form_helper.rb', line 66

def method_missing(method, *args)
  if method.to_s.match(/(.+)_(gt|gt_or_eq|eq|not_eq|lt_or_eq|lt|null|not_null|cont)/)
    @query.send(:[], method)
  else
    super
  end
end

Instance Method Details

#original_model_class_nameObject


79
80
81
# File 'app/helpers/rails/add_ons/search_form_helper.rb', line 79

def original_model_class_name
  @collection.class.to_s.deconstantize
end