Class: Shark::Permissions::Changes
- Inherits:
-
Object
- Object
- Shark::Permissions::Changes
- Defined in:
- lib/shark/permissions/changes.rb
Instance Attribute Summary collapse
-
#effect ⇒ Object
readonly
Returns the value of attribute effect.
-
#privileges ⇒ Object
readonly
Returns the value of attribute privileges.
Instance Method Summary collapse
- #add(field, old_value, new_value) ⇒ Object
- #add_privilege(key, old_value, new_value) ⇒ Object
- #empty? ⇒ Boolean
-
#initialize ⇒ Changes
constructor
A new instance of Changes.
- #present? ⇒ Boolean
Constructor Details
#initialize ⇒ Changes
Returns a new instance of Changes.
9 10 11 12 |
# File 'lib/shark/permissions/changes.rb', line 9 def initialize @privileges = {} @effect = {} end |
Instance Attribute Details
#effect ⇒ Object (readonly)
Returns the value of attribute effect.
6 7 8 |
# File 'lib/shark/permissions/changes.rb', line 6 def effect @effect end |
#privileges ⇒ Object (readonly)
Returns the value of attribute privileges.
7 8 9 |
# File 'lib/shark/permissions/changes.rb', line 7 def privileges @privileges end |
Instance Method Details
#add(field, old_value, new_value) ⇒ Object
14 15 16 17 18 |
# File 'lib/shark/permissions/changes.rb', line 14 def add(field, old_value, new_value) return if old_value == new_value instance_variable_set("@#{field}", { old: old_value, new: old_value }) end |
#add_privilege(key, old_value, new_value) ⇒ Object
20 21 22 23 24 25 |
# File 'lib/shark/permissions/changes.rb', line 20 def add_privilege(key, old_value, new_value) @privileges[:old] ||= {} @privileges[:new] ||= {} @privileges[:old][key] = old_value @privileges[:new][key] = new_value end |
#empty? ⇒ Boolean
29 30 31 |
# File 'lib/shark/permissions/changes.rb', line 29 def empty? effect.empty? && privileges.empty? end |
#present? ⇒ Boolean
35 36 37 |
# File 'lib/shark/permissions/changes.rb', line 35 def present? !empty? end |