Skip to content

Commit

Permalink
updated repository to return indifferent hashes for items
Browse files Browse the repository at this point in the history
  • Loading branch information
vaughanbrittonsage committed Apr 27, 2017
1 parent 2b0a3b7 commit e3fe6b0
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 6 deletions.
2 changes: 1 addition & 1 deletion dynamodb_framework.gemspec
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ Gem::Specification.new do |spec|
spec.add_development_dependency "rake", "~> 10.0"
spec.add_development_dependency 'rspec'
spec.add_development_dependency 'pry'
spec.add_dependency 'hash_kit'
spec.add_dependency 'hash_kit', '~> 0.5'
spec.add_dependency 'json'
spec.add_dependency 'aws-sdk-core'
end
4 changes: 4 additions & 0 deletions lib/dynamodb_framework/dynamodb_repository.rb
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,7 @@ def get_by_key(partition_key, partition_value, range_key = nil, range_value = ni
}

result = dynamodb.client.get_item(params)
hash_helper.hash_kit.indifferent!(result.item)
return result.item

end
Expand All @@ -95,6 +96,7 @@ def all

output = []
result.items.each do |item|
hash_helper.hash_kit.indifferent!(item)
output.push(item)
end

Expand Down Expand Up @@ -144,6 +146,7 @@ def scan(expression, expression_params, limit = nil, count = false)
else
output = []
result.items.each do |item|
hash_helper.hash_kit.indifferent!(item)
output.push(item)
end

Expand Down Expand Up @@ -204,6 +207,7 @@ def query(partition_key_name, partition_key_value, range_key_name = nil, range_k
else
output = []
result.items.each do |item|
hash_helper.hash_kit.indifferent!(item)
output.push(item)
end

Expand Down
8 changes: 4 additions & 4 deletions lib/dynamodb_framework/hash_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,10 @@ def to_hash(obj)
strip_nil(hsh)
end

def hash_kit
@hash_kit ||= HashKit::Helper.new
end

private

def strip_nil(obj)
Expand All @@ -15,9 +19,5 @@ def strip_nil(obj)
end
obj.delete_if(&remove_nil)
end

def hash_kit
@hash_kit ||= HashKit::Helper.new
end
end
end
2 changes: 1 addition & 1 deletion lib/dynamodb_framework/version.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
module DynamoDbFramework
VERSION = '1.4.0'
VERSION = '1.4.1'
end

0 comments on commit e3fe6b0

Please sign in to comment.