Class: Humble::MappingConfigurationBuilder

Inherits:
Object
  • Object
show all
Defined in:
lib/humble/mapping_configuration_builder.rb

Instance Method Summary collapse

Constructor Details

#initialize(attributes = {}, table = DatabaseTable.new) ⇒ MappingConfigurationBuilder

Returns a new instance of MappingConfigurationBuilder.



3
4
5
6
# File 'lib/humble/mapping_configuration_builder.rb', line 3

def initialize(attributes = {}, table = DatabaseTable.new)
  @attributes = attributes
  @table = table
end

Instance Method Details

#buildObject



26
27
28
# File 'lib/humble/mapping_configuration_builder.rb', line 26

def build
  MappingConfiguration.new(@attributes, @table)
end

#column(name) ⇒ Object



22
23
24
# File 'lib/humble/mapping_configuration_builder.rb', line 22

def column(name)
  @table.add_column(name)
end

#primary_key(name, default: 0) ⇒ Object



17
18
19
20
# File 'lib/humble/mapping_configuration_builder.rb', line 17

def primary_key(name, default: 0)
  @attributes[:primary_key] = name
  @table.primary_key(name, default: default)
end

#table(name) ⇒ Object



8
9
10
11
# File 'lib/humble/mapping_configuration_builder.rb', line 8

def table(name)
  @attributes[:table] = name
  @table.named(name)
end

#type(name) ⇒ Object



13
14
15
# File 'lib/humble/mapping_configuration_builder.rb', line 13

def type(name)
  @attributes[:type] = name
end