class ActiveValidation::Decorators::ConsistentRegistry
Attributes
klass[R]
All items in the registry must be ancestors of this Class @return [Class]
Public Class Methods
new(klass, registry)
click to toggle source
Calls superclass method
ActiveValidation::Decorator::new
# File lib/active_validation/decorators/consistent_registry.rb, line 10 def initialize(klass, registry) super registry @klass = klass.is_a?(Class) ? klass : klass.to_s.constantize end
Public Instance Methods
find_or_add(name, &block)
click to toggle source
# File lib/active_validation/decorators/consistent_registry.rb, line 24 def find_or_add(name, &block) record = find_or_build(name, &block) registered?(name) ? record : register(name, record) end
find_or_build(name, &block)
click to toggle source
# File lib/active_validation/decorators/consistent_registry.rb, line 16 def find_or_build(name, &block) return klass.new(name, &block) unless registered?(name) found = find(name) found.instance_exec(found, &block) if block found end
register(name, item)
click to toggle source
Calls superclass method
# File lib/active_validation/decorators/consistent_registry.rb, line 29 def register(name, item) raise Errors::InconsistentRegistryError unless item.is_a? klass super end