Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Refactoing - Removed OpenStruct

  • Loading branch information...
commit c12b02356d09a5cf35a728ede8f7acfdd8d12755 1 parent 55977a3
Makoto Inoue authored
Showing with 7 additions and 7 deletions.
  1. +7 −7 lib/tc_adapter.rb
View
14 lib/tc_adapter.rb
@@ -30,8 +30,7 @@ def create(resources)
attributes = resources.first.attributes
attributes[:id] = item_id
- record = OpenStruct.new(attributes)
- item.put(item_id, Marshal.dump(record))
+ item.put(item_id, Marshal.dump(attributes))
item_id
end
@@ -68,7 +67,7 @@ def read_many(query)
raw_data = BDBCUR::new(item)
if raw_data.first
while key = raw_data.key
- results << Marshal.load(raw_data.val).marshal_dump
+ results << Marshal.load(raw_data.val)
raw_data.next
end
end
@@ -128,7 +127,7 @@ def read_one(query)
data = access_data(query.model) do |item|
raw_data = BDBCUR::new(item)
if raw_data.first
- Marshal.load(raw_data.val).marshal_dump
+ Marshal.load(raw_data.val)
end
end
end
@@ -149,7 +148,8 @@ def update(attributes, query)
record = Marshal.load(raw_data)
attributes.each do |key, value|
- record.send("#{key.name}=", value)
+ record[key.name.to_sym] = value
+ # record.send("#{key.name}=", value)
end
item.put(item_id, Marshal.dump(record))
@@ -200,7 +200,7 @@ def get_item_from_id(query, value)
raw_data = item.get(value)
# OpenStruct#marshal_dump convets OpenStruct into a hash
if raw_data
- Marshal.load(raw_data).marshal_dump
+ Marshal.load(raw_data)
end
end
end
@@ -211,7 +211,7 @@ def get_items_from_id(query, values)
access_data(query.model) do |item|
raw_data = item.get(value)
if raw_data
- Marshal.load(raw_data).marshal_dump
+ Marshal.load(raw_data)
end
end
end
Please sign in to comment.
Something went wrong with that request. Please try again.