class YuiRestClient::FilterExtractor

Attributes

full[R]
plain[R]
regex[R]

Public Class Methods

new(filter) click to toggle source
# File lib/yui_rest_client/filter_extractor.rb, line 7
def initialize(filter)
  @full = build_filters(filter)
  @plain = @full.reject { |_, v| v.is_a? Regexp }
  @regex = @full.select { |_, v| v.is_a? Regexp }
end

Public Instance Methods

to_s() click to toggle source
# File lib/yui_rest_client/filter_extractor.rb, line 13
def to_s
  full.to_s
end

Private Instance Methods

build_filters(hash) click to toggle source
# File lib/yui_rest_client/filter_extractor.rb, line 19
def build_filters(hash)
  filter = {}
  filter[:id] = hash[:id]
  # Replace '&' in label filter as search is not possible when it contains the character
  filter[:label] = hash[:label].is_a?(String) ? hash[:label].tr('&', '') : hash[:label]
  filter[:type] = hash[:class] if hash.key?(:class)
  filter.compact
end