Class: Perpetuity::MapperRegistry

Inherits:
Object
  • Object
show all
Defined in:
lib/perpetuity/mapper_registry.rb

Instance Method Summary collapse

Constructor Details

#initializeMapperRegistry

Returns a new instance of MapperRegistry.



3
4
5
# File 'lib/perpetuity/mapper_registry.rb', line 3

def initialize
  @mappers = Hash.new { |_, klass| raise KeyError, "No mapper for #{klass}" }
end

Instance Method Details

#[](klass) ⇒ Object



11
12
13
# File 'lib/perpetuity/mapper_registry.rb', line 11

def [] klass
  @mappers[klass].new(self)
end

#[]=(klass, mapper) ⇒ Object



15
16
17
# File 'lib/perpetuity/mapper_registry.rb', line 15

def []= klass, mapper
  @mappers[klass] = mapper
end

#has_mapper?(klass) ⇒ Boolean

Returns:

  • (Boolean)


7
8
9
# File 'lib/perpetuity/mapper_registry.rb', line 7

def has_mapper? klass
  @mappers.has_key? klass
end