Sha256: 047231c848001c514774ab24c42e7c9fa75daeb4a774d1471ad0876f911d4ffd

Contents?: true

Size: 939 Bytes

Versions: 18

Compression:

Stored size: 939 Bytes

Contents

require 'simple_search_filter/filter_field'

module SimpleSearchFilter
  class FilterData
    attr_accessor :values


    def values
      @values ||= {}
      @values
    end

    def v(name, v_def=nil)
      name = name.to_s
      return values[name] if v_exist?(name)
      v_def
    end

    def v_empty?(name)
      a = values
      if (a.has_key? name) && (!a[name].nil?)
        return true
      end

      false
    end

    def v_exist?(name)
      values.has_key? name
    end

    def set(name, v)
      values[name.to_s] = v
    end

    def set_values(a_values)
      @values = a_values

    end

    def clear
      @values = {}
    end

    ####

    def method_missing(method_sym, *arguments, &block)
      # the first argument is a Symbol, so you need to_s it if you want to pattern match
      name = method_sym.to_s
      if v_exist?(name)
        return v(name)
      else
        super
      end
    end


  end
end

Version data entries

18 entries across 18 versions & 1 rubygems

Version Path
simple_search_filter-0.2.1 lib/simple_search_filter/filter_data.rb
simple_search_filter-0.1.1 lib/simple_search_filter/filter_data.rb
simple_search_filter-0.1.0 lib/simple_search_filter/filter_data.rb
simple_search_filter-0.0.31 lib/simple_search_filter/filter_data.rb
simple_search_filter-0.0.30 lib/simple_search_filter/filter_data.rb
simple_search_filter-0.0.29 lib/simple_search_filter/filter_data.rb
simple_search_filter-0.0.28 lib/simple_search_filter/filter_data.rb
simple_search_filter-0.0.27 lib/simple_search_filter/filter_data.rb
simple_search_filter-0.0.26 lib/simple_search_filter/filter_data.rb
simple_search_filter-0.0.25 lib/simple_search_filter/filter_data.rb
simple_search_filter-0.0.24 lib/simple_search_filter/filter_data.rb
simple_search_filter-0.0.23 lib/simple_search_filter/filter_data.rb
simple_search_filter-0.0.22 lib/simple_search_filter/filter_data.rb
simple_search_filter-0.0.21 lib/simple_search_filter/filter_data.rb
simple_search_filter-0.0.20 lib/simple_search_filter/filter_data.rb
simple_search_filter-0.0.17 lib/simple_search_filter/filter_data.rb
simple_search_filter-0.0.16 lib/simple_search_filter/filter_data.rb
simple_search_filter-0.0.15 lib/simple_search_filter/filter_data.rb