class ActiveEntity::ConversionDefinitions::MapWithNormalizing
Public Class Methods
new()
click to toggle source
# File lib/active_entity/conversion_definitions.rb, line 35 def initialize @map = {} end
Public Instance Methods
get(type)
click to toggle source
# File lib/active_entity/conversion_definitions.rb, line 39 def get(type) @map[normalize_type(type)] end
normalize_type(type)
click to toggle source
# File lib/active_entity/conversion_definitions.rb, line 48 def normalize_type(type) case type when Class type.to_s when String type when Symbol type.to_s else raise ArgumentError.new("`type` must be a Class or String or Symbol, but #{type.class}") end end
set(type, &block)
click to toggle source
# File lib/active_entity/conversion_definitions.rb, line 43 def set(type, &block) # TODO: block arity check @map[normalize_type(type)] = block end