Commit 381c938
Changed files (5)
lib
spec
integration
fixtures
lib/humble/mapping_configuration.rb
@@ -9,12 +9,12 @@ module Humble
ResultSet.new(connection[@table.name], mapper)
end
- def save_using(connection, item)
- @table.persist(connection, item)
+ def save_using(connection, entity)
+ @table.persist(connection, entity)
end
def matches?(item)
- item == self[:type] || item.is_a?(self[:type])
+ self[:type] == item || item.is_a?(self[:type])
end
def [](key)
lib/humble/result_set.rb
@@ -15,7 +15,7 @@ module Humble
def include?(item)
self.find do |x|
- x.id == item.id
+ x == item
end
end
lib/humble/session.rb
@@ -11,8 +11,8 @@ module Humble
end
end
- def save(item)
- mapping_for(item).save_using(create_connection, item)
+ def save(entity)
+ mapping_for(entity).save_using(create_connection, entity)
end
def find_all(clazz)
@@ -27,8 +27,8 @@ module Humble
@connection ||= connection_factory.create_connection
end
- def mapping_for(item)
- mapper_registry.mapping_for(item)
+ def mapping_for(entity)
+ mapper_registry.mapping_for(entity)
end
end
end
spec/integration/fixtures/movie_mapping.rb
@@ -9,6 +9,13 @@ class Movie
def name=(new_name)
@name = new_name
end
+
+ def ==(other)
+ return false unless other
+ return false if other.id == -1
+ return false if @id == -1
+ @id == other.id
+ end
end
class MovieMapping < Humble::DatabaseMapping
Gemfile.lock
@@ -1,7 +1,7 @@
PATH
remote: .
specs:
- humble (0.0.1374363779)
+ humble (0.0.1374364444)
sequel
GEM