Module: Permissible
- Defined in:
- lib/permissible.rb,
lib/permissible/version.rb
Constant Summary collapse
- VERSION =
"0.0.1"
Class Method Summary collapse
Instance Method Summary collapse
- #add_to_list(*ids) ⇒ Object
- #blacklist(*args) ⇒ Object
- #permissible?(user) ⇒ Boolean
- #whitelist(*args) ⇒ Object
Class Method Details
.included(base) ⇒ Object
2 3 4 5 |
# File 'lib/permissible.rb', line 2 def self.included(base) base.field :list_type, :type => String, :default => "whitelist" base.field :permission_ids, :type => Array, :default => [] end |
Instance Method Details
#add_to_list(*ids) ⇒ Object
17 18 19 |
# File 'lib/permissible.rb', line 17 def add_to_list(*ids) self. = (self. + ids).compact if ids end |
#blacklist(*args) ⇒ Object
7 8 9 10 |
# File 'lib/permissible.rb', line 7 def blacklist(*args) self.list_type = "blacklist" self. = (self. + args).compact if args end |
#permissible?(user) ⇒ Boolean
21 22 23 24 25 26 27 28 29 |
# File 'lib/permissible.rb', line 21 def permissible?(user) if self.list_type == "blacklist" self..include?(user.id) ? false : true elsif self.list_type == "whitelist" self..include?(user.id) ? true : false else return nil end end |
#whitelist(*args) ⇒ Object
12 13 14 15 |
# File 'lib/permissible.rb', line 12 def whitelist(*args) self.list_type = "whitelist" self. = (self. + args).compact if args end |