Module: SearchObject::Base::ClassMethods
- Defined in:
- lib/search_object/base.rb
Instance Attribute Summary collapse
-
#config ⇒ Object
readonly
Returns the value of attribute config.
Instance Method Summary collapse
- #inherited(base) ⇒ Object
- #option(name, options = nil, &block) ⇒ Object
- #results(*args) ⇒ Object
- #scope(&block) ⇒ Object
Instance Attribute Details
permalink #config ⇒ Object (readonly)
Returns the value of attribute config.
72 73 74 |
# File 'lib/search_object/base.rb', line 72 def config @config end |
Instance Method Details
permalink #inherited(base) ⇒ Object
[View source]
74 75 76 |
# File 'lib/search_object/base.rb', line 74 def inherited(base) base.instance_variable_set '@config', Helper.deep_copy(config) end |
permalink #option(name, options = nil, &block) ⇒ Object
[View source]
82 83 84 85 86 87 88 89 90 91 92 93 |
# File 'lib/search_object/base.rb', line 82 def option(name, = nil, &block) = { default: } unless .is_a?(Hash) name = name.to_s default = [:default] handler = [:with] || block config[:defaults][name] = default unless default.nil? config[:options][name] = Helper.normalize_search_handler(handler, name) define_method(name) { @search.param name } end |
permalink #results(*args) ⇒ Object
[View source]
95 96 97 |
# File 'lib/search_object/base.rb', line 95 def results(*args) new(*args).results end |
permalink #scope(&block) ⇒ Object
[View source]
78 79 80 |
# File 'lib/search_object/base.rb', line 78 def scope(&block) config[:scope] = block end |