Class: Spine::Restrictions::Registration

Inherits:
Object
  • Object
show all
Defined in:
lib/spine/restrictions/registration.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

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

#exceptionsObject (readonly)

Returns the value of attribute exceptions.



4
5
6
# File 'lib/spine/restrictions/registration.rb', line 4

def exceptions
  @exceptions
end

#restrictionObject (readonly)

Returns the value of attribute restriction.



4
5
6
# File 'lib/spine/restrictions/registration.rb', line 4

def restriction
  @restriction
end

#restrictionsObject (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

Returns:

  • (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