Class: Tire::Suggest::MultiSuggestion
- Inherits:
-
Object
- Object
- Tire::Suggest::MultiSuggestion
- Defined in:
- lib/tire/suggest/suggestion.rb
Instance Attribute Summary collapse
-
#suggestions ⇒ Object
Returns the value of attribute suggestions.
Instance Method Summary collapse
-
#initialize(&block) ⇒ MultiSuggestion
constructor
A new instance of MultiSuggestion.
- #suggestion(name, &block) ⇒ Object
- #text(value) ⇒ Object
- #to_hash ⇒ Object
- #to_json(options = {}) ⇒ Object
Constructor Details
#initialize(&block) ⇒ MultiSuggestion
Returns a new instance of MultiSuggestion.
78 79 80 81 |
# File 'lib/tire/suggest/suggestion.rb', line 78 def initialize(&block) @value = {} block.arity < 1 ? self.instance_eval(&block) : block.call(self) if block_given? end |
Instance Attribute Details
#suggestions ⇒ Object
Returns the value of attribute suggestions.
76 77 78 |
# File 'lib/tire/suggest/suggestion.rb', line 76 def suggestions @suggestions end |
Instance Method Details
#suggestion(name, &block) ⇒ Object
88 89 90 91 92 |
# File 'lib/tire/suggest/suggestion.rb', line 88 def suggestion(name, &block) @suggestions ||= {} @suggestions.update Suggestion.new(name, &block).to_hash self end |
#text(value) ⇒ Object
83 84 85 86 |
# File 'lib/tire/suggest/suggestion.rb', line 83 def text(value) @global_text = value self end |
#to_hash ⇒ Object
94 95 96 97 98 |
# File 'lib/tire/suggest/suggestion.rb', line 94 def to_hash @value.update @suggestions @value[:text] = @global_text if @global_text @value end |
#to_json(options = {}) ⇒ Object
100 101 102 |
# File 'lib/tire/suggest/suggestion.rb', line 100 def to_json(={}) to_hash.to_json end |