class Seeker::Base

Public Class Methods

construct(model) click to toggle source
# File lib/seeker/base.rb, line 4
def self.construct(model)
  self.model = model
  model.searchable(@_searchable_options, &@_searchable) if @_searchable
  self
end
model_name() click to toggle source
# File lib/seeker/base.rb, line 30
def self.model_name
  @_model_name ||= ActiveModel::Name.new self
end
new(params={}) click to toggle source
# File lib/seeker/base.rb, line 10
def initialize(params={})
  assign params
end
searchable(searchable_options = {}, &block) click to toggle source
# File lib/seeker/base.rb, line 34
def self.searchable(searchable_options = {}, &block)
  @_searchable_options = searchable_options
  @_searchable = block
end

Public Instance Methods

assign(params) click to toggle source
# File lib/seeker/base.rb, line 14
def assign(params)
  params.each do |attr, value|
    self.public_send("#{attr}=", value)
  end
  
  self
end
model_name() click to toggle source
# File lib/seeker/base.rb, line 22
def model_name
  self.class.model_name
end
options() click to toggle source
# File lib/seeker/base.rb, line 42
def options
  {}
end
persisted?() click to toggle source

force plural route in ActionDispatch::Routing::PolymorphicRoutes#polymorphic_url

# File lib/seeker/base.rb, line 55
def persisted?
  false
end
results() click to toggle source
# File lib/seeker/base.rb, line 50
def results
  seek.results
end
seek() click to toggle source
# File lib/seeker/base.rb, line 46
def seek
  self.class.model.search(options, &method(:search))
end
to_key() click to toggle source

for ActionController::RecordIdentifier#record_key_for_dom_id

# File lib/seeker/base.rb, line 60
def to_key
  nil
end
to_model() click to toggle source
# File lib/seeker/base.rb, line 26
def to_model
  model.new
end