Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

single_day? and multi_day? methods #3

Merged
merged 1 commit into from Jun 20, 2011
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
8 changes: 8 additions & 0 deletions app/models/event.rb
Expand Up @@ -54,6 +54,14 @@ def next
def prev def prev
Event.where(['start_at < ?', start_at]).reverse.first Event.where(['start_at < ?', start_at]).reverse.first
end end

def single_day?
end_at.blank? || start_at.blank? || (end_at - start_at) < 24*60*60
end

def multi_day?
!single_day?
end


def self.archive def self.archive
with_exclusive_scope { order('start_at DESC').where 'end_at < ?', Time.now } with_exclusive_scope { order('start_at DESC').where 'end_at < ?', Time.now }
Expand Down
2 changes: 1 addition & 1 deletion spec/models/event_spec.rb
Expand Up @@ -74,4 +74,4 @@ def reset_event(options = {})


end end


end end