class Bronto::Filter
Attributes
fields[RW]
type[RW]
Public Class Methods
new()
click to toggle source
# File lib/bronto/filter.rb, line 8 def initialize self.fields = {} end
Public Instance Methods
add_filter(*args)
click to toggle source
Accepts two or three arguments:
1. Field name 2. (optional) The operator to use (only available for certain fields; see the filter documentation). 3. Value
# File lib/bronto/filter.rb, line 21 def add_filter(*args) raise ArgumentError, "wrong number of arguments (#{args.length} for 2..3)" if args.length != 2 and args.length != 3 field = args.shift.to_sym self.fields[field] = [] unless self.fields.has_key?(field) if args.length == 1 self.fields[field] << args.first else self.fields[field] << { operator: args.first, value: args.last } end self end
to_hash()
click to toggle source
# File lib/bronto/filter.rb, line 12 def to_hash hash = { type: type || "AND" } hash.merge(fields) end