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
# File 'lib/restrict/restriction.rb', line 5

def initialize(*args)
  options  = args.extract_options!
  @unless  = options[:unless]
  @actions = args
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

#unlessObject

Returns the value of attribute unless.



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

def unless
  @unless
end

Instance Method Details

#applies_to?(action) ⇒ Boolean

Returns:

  • (Boolean)


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

def applies_to?(action)
  applies_to_action?(action) || applies_to_all_actions?
end