Created
January 14, 2013 23:05
-
-
Save arbarlow/4534388 to your computer and use it in GitHub Desktop.
This file contains 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
module ActsAsPublic | |
extend ActiveSupport::Concern | |
# This modules assumes you have a column | |
# called 'public' that is by default true | |
included do | |
default_scope where(public: true) | |
end | |
module ClassMethods | |
def not_public | |
where(public: false) | |
end | |
end | |
# Instance methods | |
def make_public! | |
self.public = true | |
save | |
end | |
def make_hidden! | |
self.public = false | |
save | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment