lib/muster/results.rb
def filter(key, *options)
      if options.present? && options.first.instance_of?(Hash)
        options = options.first.with_indifferent_access

        if options.key?(:only)
          return filter_only_values(key, options[:only])
        elsif options.key?(:except)
          return filter_excluded_values(key, options[:except])
        end
      else
        return fetch(key, *options)
      end
    end
def filter(key, *options)
      if options.present? && options.first.instance_of?(Hash)
        options = options.first.with_indifferent_access

        if options.key?(:only)
          return filter_only_values(key, options[:only])
        elsif options.key?(:except)
          return filter_excluded_values(key, options[:except])
        end
      else
        return fetch(key, *options)
      end
    end
def filter ( key , * options ) if options . present? && options . first . instance_of? ( Hash ) options = options . first . with_indifferent_access if options . key? ( :only ) return filter_only_values ( key , options [ :only ] ) elsif options . key? ( :except ) return filter_excluded_values ( key , options [ :except ] ) end else return fetch ( key , options ) end end
Filters and returns the raw data values for the specifid key and options

 @param key [String,Symbol] the key of the values in {#data} to filter
 @param [optional, Hash] options the options available for this filter
 @option options [optional] :only when specified, only return the matching values
   If you specify a single value, a single value will be returned
   If you specify an Array of values, an Array will be returned, even if only one value matches
 @option options [optional] :except return all values except the ones given here
   If the raw data value is a single value, a single value will be returned
   If the raw data value is an Array, and array will be returned, even if all values are excluded
   If nothing was excluded, the raw value is returned as-is

 If you pass a scalar value instead of a Hash into options, it will be treated as the default, just like
 Hash#fetch does.

 If you pass nothing into the options argument, it will return all values if the key exists or raise
 a KeyError like Hash#fetch.

 @return [void]

 @example

   data = { :select => [:id, :name, :created_at] }
   results = Muster::Results.new(data)
   results.filter(:select)                            #=> [:id, :name, :created_at]
   results.filter(:select, :only => :name)            #=> :name
   results.filter(:select, :only => [:other, :name])  #=> [:name]
   results.filter(:other, :default)                   #=> :default
   results.filter(:other)                             #=> KeyError
Filters and returns the raw data values for the specifid key and options