Class: Humble::MappingConfiguration

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

Instance Method Summary collapse

Constructor Details

#initialize(attributes, table) ⇒ MappingConfiguration

Returns a new instance of MappingConfiguration.



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

def initialize(attributes, table)
  @attributes = attributes
  @table = table
end

Instance Method Details

#[](key) ⇒ Object



24
25
26
# File 'lib/humble/mapping_configuration.rb', line 24

def [](key)
  @attributes[key]
end

#delete_using(connection, entity) ⇒ Object



16
17
18
# File 'lib/humble/mapping_configuration.rb', line 16

def delete_using(connection, entity)
  @table.destroy(connection, entity)
end

#find_all_using(connection) ⇒ Object



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

def find_all_using(connection)
  ResultSet.new(connection[@table.name], mapper)
end

#matches?(item) ⇒ Boolean

Returns:

  • (Boolean)


20
21
22
# File 'lib/humble/mapping_configuration.rb', line 20

def matches?(item)
  self[:type] == item || item.is_a?(self[:type])
end

#save_using(connection, entity) ⇒ Object



12
13
14
# File 'lib/humble/mapping_configuration.rb', line 12

def save_using(connection, entity)
  @table.persist(connection, entity)
end