2011-03-30 20:31:39 -04:00
|
|
|
module Ransack
|
|
|
|
module Naming
|
|
|
|
|
|
|
|
def self.included(base)
|
|
|
|
base.extend ClassMethods
|
|
|
|
end
|
|
|
|
|
|
|
|
def persisted?
|
|
|
|
false
|
|
|
|
end
|
|
|
|
|
|
|
|
def to_key
|
|
|
|
nil
|
|
|
|
end
|
|
|
|
|
|
|
|
def to_param
|
|
|
|
nil
|
|
|
|
end
|
|
|
|
|
|
|
|
def to_model
|
|
|
|
self
|
|
|
|
end
|
2015-03-31 11:55:55 -04:00
|
|
|
|
|
|
|
def model_name
|
|
|
|
self.class.model_name
|
|
|
|
end
|
2011-03-30 20:31:39 -04:00
|
|
|
end
|
|
|
|
|
|
|
|
class Name < String
|
2013-12-08 15:51:43 -05:00
|
|
|
attr_reader :singular, :plural, :element, :collection, :partial_path,
|
|
|
|
:human, :param_key, :route_key, :i18n_key
|
2011-03-30 20:31:39 -04:00
|
|
|
alias_method :cache_key, :collection
|
|
|
|
|
|
|
|
def initialize
|
2014-11-21 14:03:20 -05:00
|
|
|
super(Constants::CAP_SEARCH)
|
|
|
|
@singular = Constants::SEARCH
|
|
|
|
@plural = Constants::SEARCHES
|
|
|
|
@element = Constants::SEARCH
|
|
|
|
@human = Constants::CAP_SEARCH
|
|
|
|
@collection = Constants::RANSACK_SLASH_SEARCHES
|
|
|
|
@partial_path = Constants::RANSACK_SLASH_SEARCHES_SLASH_SEARCH
|
|
|
|
@param_key = Constants::Q
|
|
|
|
@route_key = Constants::SEARCHES
|
2014-11-21 12:45:05 -05:00
|
|
|
@i18n_key = :ransack
|
2011-03-30 20:31:39 -04:00
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
module ClassMethods
|
|
|
|
def model_name
|
|
|
|
@_model_name ||= Name.new
|
|
|
|
end
|
|
|
|
|
|
|
|
def i18n_scope
|
|
|
|
:ransack
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2014-11-20 17:56:41 -05:00
|
|
|
end
|