class Moonrope::DSL::FilterableDSL

Public Class Methods

new(action) click to toggle source
# File lib/moonrope/dsl/filterable_dsl.rb, line 5
def initialize(action)
  @action = action
end

Public Instance Methods

attribute(name, options = {}, &block) click to toggle source
# File lib/moonrope/dsl/filterable_dsl.rb, line 9
def attribute(name, options = {}, &block)
  if options[:type] == Integer || options[:type] == Float
    # Numbers
    options[:operators] ||= [:eq, :not_eq, :gt, :gte, :lt, :lte, :in, :not_in]
  elsif options[:type] == String
    # Strings
    options[:operators] ||= [:eq, :not_eq, :starts_with, :ends_with, :in, :not_in]
  elsif options[:type] == :timestamp
    # Times
    options[:operators] ||= [:eq, :not_eq, :gt, :gte, :lt, :lte]
  else
    # Everything else
    options[:operators] ||= [:eq, :not_eq]
  end
  @action.filters[name] = options.merge(:name => name, :block => block)
end