Created
August 23, 2014 09:31
-
-
Save aldesantis/82bfedd1df136c8cdbda to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require 'active_support/concern' | |
module Processable | |
extend ActiveSupport::Concern | |
included do | |
scope :processed, ->{ where processed: true } | |
scope :unprocessed, ->{ where processed: false } | |
end | |
module ClassMethods | |
# nothing here | |
end | |
def mark_as_processed! | |
update_column :processed, true | |
end | |
def mark_as_unprocessed! | |
update_column :processed, false | |
end | |
def status | |
if processed? | |
:processed | |
else | |
:unprocessed | |
end | |
end | |
def unprocessed? | |
!processed? | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment