Class: Braintree::AdvancedSearch::MultipleValueNode

Inherits:
SearchNode
  • Object
show all
Defined in:
lib/braintree/advanced_search.rb

Direct Known Subclasses

MultipleValueOrTextNode

Instance Method Summary collapse

Methods inherited from SearchNode

operators

Constructor Details

#initialize(name, parent, options) ⇒ MultipleValueNode

Returns a new instance of MultipleValueNode.



51
52
53
54
# File 'lib/braintree/advanced_search.rb', line 51

def initialize(name, parent, options)
  super(name, parent)
  @options = options
end

Instance Method Details

#allowed_valuesObject



56
57
58
# File 'lib/braintree/advanced_search.rb', line 56

def allowed_values
  @options[:allows]
end

#in(*values) ⇒ Object



40
41
42
43
44
45
46
47
48
49
# File 'lib/braintree/advanced_search.rb', line 40

def in(*values)
  values.flatten!

  unless allowed_values.nil?
    bad_values = values - allowed_values
    raise ArgumentError.new("Invalid argument(s) for #{@node_name}: #{bad_values.join(", ")}") if bad_values.any?
  end

  @parent.add_criteria(@node_name, values)
end

#is(value) ⇒ Object



60
61
62
# File 'lib/braintree/advanced_search.rb', line 60

def is(value)
  self.in(value)
end