Class: Humble::MappingConfigurationBuilder
- Inherits:
-
Object
- Object
- Humble::MappingConfigurationBuilder
- Defined in:
- lib/humble/mapping_configuration_builder.rb
Instance Method Summary collapse
- #build ⇒ Object
- #column(name) ⇒ Object
-
#initialize(attributes = {}, table = DatabaseTable.new) ⇒ MappingConfigurationBuilder
constructor
A new instance of MappingConfigurationBuilder.
- #primary_key(name, default: 0) ⇒ Object
- #table(name) ⇒ Object
- #type(name) ⇒ Object
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
#build ⇒ Object
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 |