Module: TalentScout::Controller::ClassMethods
- Defined in:
- lib/talent_scout/controller.rb
Instance Method Summary collapse
-
#model_search_class ⇒ Class<TalentScout::ModelSearch>
Returns the controller model search class.
-
#model_search_class=(klass) ⇒ Class<TalentScout::ModelSearch>
Sets the controller model search class.
-
#model_search_class? ⇒ Class<TalentScout::ModelSearch>?
Similar to #model_search_class, but returns nil instead of raising an error when the value has not been set and the default class does not exist.
Instance Method Details
#model_search_class ⇒ Class<TalentScout::ModelSearch>
Returns the controller model search class. Defaults to a class corresponding to the singular form of the controller name. The model search class can also be set with #model_search_class=. If the model search class has not been set, and the default class does not exist, a NameError
will be raised.
22 23 24 |
# File 'lib/talent_scout/controller.rb', line 22 def model_search_class @model_search_class ||= "#{controller_path.classify}Search".constantize end |
#model_search_class=(klass) ⇒ Class<TalentScout::ModelSearch>
Sets the controller model search class. See #model_search_class.
30 31 32 |
# File 'lib/talent_scout/controller.rb', line 30 def model_search_class=(klass) @model_search_class = klass end |
#model_search_class? ⇒ Class<TalentScout::ModelSearch>?
Similar to #model_search_class, but returns nil instead of raising an error when the value has not been set and the default class does not exist.
39 40 41 42 43 44 45 46 |
# File 'lib/talent_scout/controller.rb', line 39 def model_search_class? return @model_search_class if defined?(@model_search_class) begin model_search_class rescue NameError @model_search_class = nil end end |