Module: IncludeDateScopes::DateScopes::ClassMethods

Defined in:
lib/include_date_scopes/date_scopes.rb

Instance Method Summary collapse

Instance Method Details

#include_date_scopesObject



29
30
31
# File 'lib/include_date_scopes/date_scopes.rb', line 29

def include_date_scopes
  include_date_scopes_for :created_at
end

#include_date_scopes_for(column, prepend_name = false) ⇒ Object



33
34
35
36
37
38
39
40
# File 'lib/include_date_scopes/date_scopes.rb', line 33

def include_date_scopes_for(column, prepend_name = false)
  return unless self.table_exists?
  if self.columns_hash[column.to_s].type == :datetime
    define_timestamp_scopes_for column, prepend_name
  elsif self.columns_hash[column.to_s].type == :date
    define_date_scopes_for column, prepend_name
  end
end

#include_named_date_scopes_for(column) ⇒ Object



42
43
44
# File 'lib/include_date_scopes/date_scopes.rb', line 42

def include_named_date_scopes_for(column)
  include_date_scopes_for column, true
end