Class: Toolbelt::Policy

Inherits:
Object
  • Object
show all
Includes:
Util::OptionValidator
Defined in:
lib/toolbelt/policy.rb

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Methods included from Util::OptionValidator

#required_options, #validate_options!

Constructor Details

#initialize(options = {}) ⇒ Policy

Returns a new instance of Policy.



15
16
17
18
# File 'lib/toolbelt/policy.rb', line 15

def initialize(options = {})
  validate_options!(options)
  @options = Hashie::Mash.new(options)
end

Instance Attribute Details

#optionsObject (readonly)

Returns the value of attribute options.



5
6
7
# File 'lib/toolbelt/policy.rb', line 5

def options
  @options
end

Class Method Details

.fail?(options = {}) ⇒ Boolean

Returns:

  • (Boolean)


11
12
13
# File 'lib/toolbelt/policy.rb', line 11

def self.fail?(options = {})
  new(options).fail?
end

.pass?(options = {}) ⇒ Boolean

Returns:

  • (Boolean)


7
8
9
# File 'lib/toolbelt/policy.rb', line 7

def self.pass?(options = {})
  new(options).pass?
end

Instance Method Details

#fail?Boolean

Returns:

  • (Boolean)


24
25
26
# File 'lib/toolbelt/policy.rb', line 24

def fail?
  !pass?
end

#pass?Boolean

Returns:

  • (Boolean)


20
21
22
# File 'lib/toolbelt/policy.rb', line 20

def pass?
  fail Toolbelt::OverrideInSubclassError
end