Class: Spine::Restrictions::Registration
- Inherits:
-
Object
- Object
- Spine::Restrictions::Registration
- Defined in:
- lib/spine/restrictions/registration.rb
Instance Attribute Summary collapse
-
#exceptions ⇒ Object
readonly
Returns the value of attribute exceptions.
-
#restriction ⇒ Object
readonly
Returns the value of attribute restriction.
-
#restrictions ⇒ Object
readonly
Returns the value of attribute restrictions.
Instance Method Summary collapse
- #applies?(action, resource) ⇒ Boolean
- #except(action, resource) ⇒ Object
-
#initialize(restriction) ⇒ Registration
constructor
A new instance of Registration.
- #restrict(action, resource) ⇒ Object
Constructor Details
#initialize(restriction) ⇒ Registration
Returns a new instance of Registration.
6 7 8 9 10 |
# File 'lib/spine/restrictions/registration.rb', line 6 def initialize(restriction) @restriction = restriction @exceptions = {} @restrictions = {} end |
Instance Attribute Details
#exceptions ⇒ Object (readonly)
Returns the value of attribute exceptions.
4 5 6 |
# File 'lib/spine/restrictions/registration.rb', line 4 def exceptions @exceptions end |
#restriction ⇒ Object (readonly)
Returns the value of attribute restriction.
4 5 6 |
# File 'lib/spine/restrictions/registration.rb', line 4 def restriction @restriction end |
#restrictions ⇒ Object (readonly)
Returns the value of attribute restrictions.
4 5 6 |
# File 'lib/spine/restrictions/registration.rb', line 4 def restrictions @restrictions end |
Instance Method Details
#applies?(action, resource) ⇒ Boolean
22 23 24 25 26 |
# File 'lib/spine/restrictions/registration.rb', line 22 def applies?(action, resource) return false if exception?(action, resource) includes?(restrictions, action, resource) end |
#except(action, resource) ⇒ Object
17 18 19 20 |
# File 'lib/spine/restrictions/registration.rb', line 17 def except(action, resource) add(exceptions, action, resource) self end |
#restrict(action, resource) ⇒ Object
12 13 14 15 |
# File 'lib/spine/restrictions/registration.rb', line 12 def restrict(action, resource) add(restrictions, action, resource) self end |