class Attrocity::CoercerRegistry

Public Class Methods

add(name, coercer_class) click to toggle source
# File lib/attrocity/coercer_registry.rb, line 10
def self.add(name, coercer_class)
  registry[name] = coercer_class
end
coercer_for(name) click to toggle source
# File lib/attrocity/coercer_registry.rb, line 18
def self.coercer_for(name)
  registry.fetch(name)
rescue KeyError
  raise UnknownCoercerError
end
instance_for(name, params={}) click to toggle source
# File lib/attrocity/coercer_registry.rb, line 24
def self.instance_for(name, params={})
  if params.empty?
    coercer_for(name).new
  else
    coercer_for(name).new(params)
  end
end
register(&block) click to toggle source
# File lib/attrocity/coercer_registry.rb, line 6
def self.register(&block)
  class_eval(&block) if block_given?
end
to_s() click to toggle source
# File lib/attrocity/coercer_registry.rb, line 14
def self.to_s
  registry.inspect
end

Private Class Methods

registry() click to toggle source
# File lib/attrocity/coercer_registry.rb, line 34
def self.registry
  @registry ||= {}
end