summaryrefslogtreecommitdiff
path: root/lib/oxidized/source
diff options
context:
space:
mode:
authorSaku Ytti <saku@ytti.fi>2013-04-24 19:46:07 +0300
committerSaku Ytti <saku@ytti.fi>2013-04-24 19:46:07 +0300
commitd4e251b42ff4f4831762912e2ad3d50b91e8afb0 (patch)
treeb6c9907f43bb58acdc0d4a96022463f1a01bee19 /lib/oxidized/source
parent92d61ebb88dda29d1168be3d3436761869c97439 (diff)
Remove Sequel model
No point creating the model for one-off use, especially with dodgy dynamic consts
Diffstat (limited to 'lib/oxidized/source')
-rw-r--r--lib/oxidized/source/sql.rb9
1 files changed, 3 insertions, 6 deletions
diff --git a/lib/oxidized/source/sql.rb b/lib/oxidized/source/sql.rb
index 44f3f00..c563e15 100644
--- a/lib/oxidized/source/sql.rb
+++ b/lib/oxidized/source/sql.rb
@@ -24,17 +24,14 @@ class SQL < Source
def load
nodes = []
- case @cfg[:adapter]
+ db = case @cfg[:adapter]
when 'sqlite'
require 'sqlite3'
Sequel.sqlite @cfg[:file]
end
- klass = Class.new(Sequel::Model @cfg[:table].to_sym)
- SQL.send :remove_const, :Nodes if SQL.const_defined? :Nodes
- SQL.const_set :Nodes, klass
- Nodes.each do |node|
+ db[@cfg[:table].to_sym].each do |node|
keys = {}
- @cfg[:map].each { |key, sql_column| keys[key] = node.send(sql_column.to_sym) }
+ @cfg[:map].each { |key, sql_column| keys[key] = node[sql_column.to_sym] }
keys[:model] = map_model keys[:model] if keys.key? :model
nodes << keys
end