Module: Permissify::Model
Instance Attribute Summary collapse
-
#from ⇒ Object
Returns the value of attribute from.
-
#from_permissions_model ⇒ Object
Returns the value of attribute from_permissions_model.
Instance Method Summary collapse
- #allows?(ability_key) ⇒ Boolean
- #establish_from_permissions_model ⇒ Object
- #initialize_permissions ⇒ Object
- #remove_permissions(keys) ⇒ Object
- #underscored_name_symbol ⇒ Object
- #update_permissions(new_or_updated_permissions) ⇒ Object
Instance Attribute Details
#from ⇒ Object
Returns the value of attribute from.
3 4 5 |
# File 'lib/permissify/model.rb', line 3 def from @from end |
#from_permissions_model ⇒ Object
Returns the value of attribute from_permissions_model.
3 4 5 |
# File 'lib/permissify/model.rb', line 3 def @from_permissions_model end |
Instance Method Details
#allows?(ability_key) ⇒ Boolean
13 14 15 16 17 |
# File 'lib/permissify/model.rb', line 13 def allows?(ability_key) allowed = self.[ability_key]; # allowed && allowed['0'] allowed && (allowed['0'] == '1') end |
#establish_from_permissions_model ⇒ Object
5 6 7 |
# File 'lib/permissify/model.rb', line 5 def self. ||= self.from.nil? ? nil : self.class.find(self.from) end |
#initialize_permissions ⇒ Object
9 10 11 |
# File 'lib/permissify/model.rb', line 9 def self. ||= self.from.nil? ? {} : . end |
#remove_permissions(keys) ⇒ Object
19 20 21 22 23 |
# File 'lib/permissify/model.rb', line 19 def (keys) keys = [keys] if keys.class != Array keys.each{ |k| self.[k] = nil} self.save end |
#underscored_name_symbol ⇒ Object
30 31 32 |
# File 'lib/permissify/model.rb', line 30 def underscored_name_symbol self.class.underscored_name_symbol(self.name) end |
#update_permissions(new_or_updated_permissions) ⇒ Object
25 26 27 28 |
# File 'lib/permissify/model.rb', line 25 def () self. = self..merge() self.save end |