class Right::FilterParameters

Constants

FilterError

Attributes

parameters[R]

Public Class Methods

new(parameters = nil) click to toggle source

@param [<Right::FilterParameter>]

# File lib/right/filter_parameters.rb, line 14
def initialize(parameters = nil)
  @parameters = Set.new(parameters)
end

Public Instance Methods

+(other) click to toggle source

param other [Right::FilterParameters]

# File lib/right/filter_parameters.rb, line 72
def +(other)
  self.class.new(parameters.merge(other.parameters))
end
-(other) click to toggle source

param other [Right::FilterParameters]

# File lib/right/filter_parameters.rb, line 67
def -(other)
  self.class.new(parameters - other.parameters)
end
<<(value)
Alias for: add
<=>(other) click to toggle source
# File lib/right/filter_parameters.rb, line 85
def <=>(other)
  parameters <=> other.parameters
end
[](name) click to toggle source

Find filter by name @param name [String] @return [Right::FilterParameter, nil]

# File lib/right/filter_parameters.rb, line 34
def [](name)
  parameters.detect { |filter| filter.name == name }
end
add(value) click to toggle source

param value [Right::FilterParameter]

# File lib/right/filter_parameters.rb, line 56
def add(value)
  self.class.new(parameters.add(value))
end
Also aliased as: <<
delete(name) click to toggle source

Delete filter by name @param name [String] @return [Right::FilterParameter, nil]

# File lib/right/filter_parameters.rb, line 79
def delete(name)
  filter_parameter = self[name]
  parameters.delete(filter_parameter) if filter_parameter
  filter_parameter
end
fetch(name) { |name| ... } click to toggle source

Find filter by name or raise error @param name [String] @yieldparam name [String]

block value will be returned if no `FilterParameter` found with specified name

@return [Right::FilterParameter] @raise FilterError

# File lib/right/filter_parameters.rb, line 45
def fetch(name)
  if (filter = self[name])
    filter
  elsif block_given?
    yield(name)
  else
    fail FilterError, "filter not found: #{name.inspect}"
  end
end
initialize_clone(orig) click to toggle source

Clone internal set.

Calls superclass method
# File lib/right/filter_parameters.rb, line 25
def initialize_clone(orig)
  super
  @parameters = orig.parameters.clone
end
initialize_dup(orig) click to toggle source

Dup internal set.

Calls superclass method
# File lib/right/filter_parameters.rb, line 19
def initialize_dup(orig)
  super
  @parameters = orig.parameters.dup
end
map(&block) click to toggle source
# File lib/right/filter_parameters.rb, line 62
def map(&block)
  self.class.new(parameters.map(&block))
end