Class: Qiita::Elasticsearch::Nodes::FilterableNode
- Inherits:
-
Object
- Object
- Qiita::Elasticsearch::Nodes::FilterableNode
- Defined in:
- lib/qiita/elasticsearch/nodes/filterable_node.rb
Instance Method Summary collapse
-
#initialize(tokens) ⇒ FilterableNode
constructor
A new instance of FilterableNode.
- #to_hash ⇒ Object
Constructor Details
#initialize(tokens) ⇒ FilterableNode
Returns a new instance of FilterableNode.
9 10 11 |
# File 'lib/qiita/elasticsearch/nodes/filterable_node.rb', line 9 def initialize(tokens) @tokens = tokens end |
Instance Method Details
#to_hash ⇒ Object
13 14 15 16 17 18 19 20 21 22 23 24 25 26 |
# File 'lib/qiita/elasticsearch/nodes/filterable_node.rb', line 13 def to_hash if filter_tokens.empty? QueryNode.new(not_filter_tokens).to_hash else { "filtered" => { "filter" => FilterNode.new(filter_tokens).to_hash, "query" => QueryNode.new(not_filter_tokens).to_hash, }.reject do |key, value| value.empty? end, } end end |