class DateSupercharger::Matcher

Attributes

attribute[RW]
suffix[RW]

Public Class Methods

new(model,method_sym) click to toggle source
# File lib/date_supercharger/matcher.rb, line 6
def initialize(model,method_sym)
  if method_sym.to_s =~ /^(.+)_(before|after|before_or_at|after_or_at|between|between_inclusive)$/
    date_columns = get_date_columns(model)

    if date_columns.include? $1.to_sym
      @attribute = $1.to_sym
      @suffix = $2.to_sym
    end
  end

end

Public Instance Methods

match?() click to toggle source
# File lib/date_supercharger/matcher.rb, line 18
def match?
  @attribute != nil
end

Private Instance Methods

get_date_columns(model) click to toggle source
# File lib/date_supercharger/matcher.rb, line 24
def get_date_columns(model)
  model.columns_hash.keys.select do |c|
    [:datetime,:date].include? model.columns_hash[c].type
  end.map(&:to_sym)
end