class Spine::Restrictions::Collection

Attributes

registrations[R]

Public Class Methods

new() click to toggle source
# File lib/spine/restrictions/collection.rb, line 6
def initialize
  @registrations = []
end

Public Instance Methods

register(restriction) click to toggle source
# File lib/spine/restrictions/collection.rb, line 10
def register(restriction)
  registration = Registration.new(restriction)
  registrations.unshift(registration)
  registration
end
restricted?(context, action, resource) click to toggle source
# File lib/spine/restrictions/collection.rb, line 16
def restricted?(context, action, resource)
  restrictions(action, resource).detect { |restriction|
    restriction.restricted?(context)
  }
end
restrictions(action, resource) click to toggle source
# File lib/spine/restrictions/collection.rb, line 22
def restrictions(action, resource)
  registrations.select { |registration|
    registration.applies?(action, resource)
  }.map { |registration|
    registration.restriction
  }
end