Class: Paradocs::Registry

Inherits:
Object show all
Defined in:
lib/paradocs/registry.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeRegistry

Returns a new instance of Registry.



9
10
11
# File 'lib/paradocs/registry.rb', line 9

def initialize
  @policies = {}
end

Instance Attribute Details

#policiesObject (readonly)

Returns the value of attribute policies.



7
8
9
# File 'lib/paradocs/registry.rb', line 7

def policies
  @policies
end

Instance Method Details

#coercionsObject



13
14
15
# File 'lib/paradocs/registry.rb', line 13

def coercions
  policies
end

#policy(name, plcy = nil, &block) ⇒ Object



17
18
19
20
21
22
# File 'lib/paradocs/registry.rb', line 17

def policy(name, plcy = nil, &block)
  validate_policy_class(plcy) if plcy

  policies[name] = (plcy || BasePolicy.build(name, :instance_eval, &block))
  self
end