Skip to content

Instantly share code, notes, and snippets.

@aldesantis
Created August 23, 2014 09:31
Show Gist options
  • Save aldesantis/82bfedd1df136c8cdbda to your computer and use it in GitHub Desktop.
Save aldesantis/82bfedd1df136c8cdbda to your computer and use it in GitHub Desktop.
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