Class: Restrict::Restriction

Inherits:
Object
  • Object
show all
Defined in:
lib/restrict/restriction.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(*args) ⇒ Restriction

Returns a new instance of Restriction.



5
6
7
8
9
10
# File 'lib/restrict/restriction.rb', line 5

def initialize(*args)
  options   = args.extract_options!
  @allow_if = options[:allow_if]
  @actions  = args
  actions.empty? and raise ArgumentError, "expected actions to restrict, but got #{actions.inspect}"
end

Instance Attribute Details

#actionsObject

Returns the value of attribute actions.



3
4
5
# File 'lib/restrict/restriction.rb', line 3

def actions
  @actions
end

#allow_ifObject

Returns the value of attribute allow_if.



3
4
5
# File 'lib/restrict/restriction.rb', line 3

def allow_if
  @allow_if
end

Instance Method Details

#concerning?(action) ⇒ Boolean

Returns:

  • (Boolean)


12
13
14
# File 'lib/restrict/restriction.rb', line 12

def concerning?(action)
  concerns_action?(action) || concerns_all?
end