Class: SearchableBy::Config
- Inherits:
-
Object
- Object
- SearchableBy::Config
- Defined in:
- lib/searchable_by/config.rb
Instance Attribute Summary collapse
-
#columns ⇒ Object
readonly
Returns the value of attribute columns.
-
#max_terms ⇒ Object
Returns the value of attribute max_terms.
-
#min_length ⇒ Object
Returns the value of attribute min_length.
-
#options ⇒ Object
readonly
Returns the value of attribute options.
-
#scoping ⇒ Object
readonly
Returns the value of attribute scoping.
Instance Method Summary collapse
- #column(*attrs, &block) ⇒ Object
- #configure(max_terms, min_length, **options, &block) ⇒ Object
-
#initialize ⇒ Config
constructor
A new instance of Config.
- #initialize_copy(other) ⇒ Object
- #scope(&block) ⇒ Object
Constructor Details
#initialize ⇒ Config
Returns a new instance of Config.
6 7 8 9 10 11 12 |
# File 'lib/searchable_by/config.rb', line 6 def initialize @columns = [] @max_terms = 5 @min_length = 0 @options = {} scope { all } end |
Instance Attribute Details
#columns ⇒ Object (readonly)
Returns the value of attribute columns.
3 4 5 |
# File 'lib/searchable_by/config.rb', line 3 def columns @columns end |
#max_terms ⇒ Object
Returns the value of attribute max_terms.
4 5 6 |
# File 'lib/searchable_by/config.rb', line 4 def max_terms @max_terms end |
#min_length ⇒ Object
Returns the value of attribute min_length.
4 5 6 |
# File 'lib/searchable_by/config.rb', line 4 def min_length @min_length end |
#options ⇒ Object (readonly)
Returns the value of attribute options.
3 4 5 |
# File 'lib/searchable_by/config.rb', line 3 def @options end |
#scoping ⇒ Object (readonly)
Returns the value of attribute scoping.
3 4 5 |
# File 'lib/searchable_by/config.rb', line 3 def scoping @scoping end |
Instance Method Details
#column(*attrs, &block) ⇒ Object
26 27 28 29 30 31 32 33 |
# File 'lib/searchable_by/config.rb', line 26 def column(*attrs, &block) opts = attrs. attrs.each do |attr| columns.push Column.new(attr, **@options, **opts) end columns.push Column.new(block, **@options, **opts) if block columns end |
#configure(max_terms, min_length, **options, &block) ⇒ Object
14 15 16 17 18 19 |
# File 'lib/searchable_by/config.rb', line 14 def configure(max_terms, min_length, **, &block) instance_eval(&block) self.max_terms = max_terms if max_terms self.min_length = min_length self..update() unless .empty? end |
#initialize_copy(other) ⇒ Object
21 22 23 24 |
# File 'lib/searchable_by/config.rb', line 21 def initialize_copy(other) @columns = other.columns.dup super end |
#scope(&block) ⇒ Object
35 36 37 |
# File 'lib/searchable_by/config.rb', line 35 def scope(&block) @scoping = block end |