Class: Collective::Policy::Instance
- Inherits:
-
Object
- Object
- Collective::Policy::Instance
show all
- Defined in:
- lib/collective/policy.rb
Instance Method Summary
collapse
Constructor Details
#initialize(options = {}) ⇒ Instance
including options will merge over these options
25
26
27
28
29
30
31
32
33
34
35
|
# File 'lib/collective/policy.rb', line 25
def initialize( options = {} )
if options[:policy] then
policy = options.delete(:policy)
defaults = policy.dup
else
defaults = DEFAULTS
end
options = Hash[ options.map { |k,v| [ k.to_sym, v ] } ] @options = defaults.merge( options )
end
|
Dynamic Method Handling
This class handles dynamic methods through the method_missing method
#method_missing(symbol, *arguments) ⇒ Object
41
42
43
|
# File 'lib/collective/policy.rb', line 41
def method_missing( symbol, *arguments )
@options[symbol.to_sym]
end
|
Instance Method Details
#after_fork ⇒ Object
53
54
55
|
# File 'lib/collective/policy.rb', line 53
def after_fork
(after_forks || []).each { |f| f.call }
end
|
#before_fork ⇒ Object
49
50
51
|
# File 'lib/collective/policy.rb', line 49
def before_fork
(before_forks || []).each { |f| f.call }
end
|
#dup ⇒ Object
45
46
47
|
# File 'lib/collective/policy.rb', line 45
def dup
@options.dup
end
|