-
-
Save nthj/895232 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 AccessibleBlock | |
extend ActiveSupport::Concern | |
module ClassMethods | |
@accessible_block = false | |
def key(*arguments, &block) | |
super | |
attr_accessible arguments[0] if @accessible_block | |
end | |
def attr_accessible(*attrs) | |
if block_given? | |
@accessible_block = true | |
yield | |
@accessible_block = false | |
else | |
super | |
end | |
end | |
end | |
end |
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
autoload :AccessibleBlock, 'lib/accessible_block' |
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
class Model | |
include MongoMapper::Document | |
plugin AccessibleBlock | |
attr_accessible do | |
key :somekey | |
key :another key | |
end | |
key :private_key | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment