From d4e251b42ff4f4831762912e2ad3d50b91e8afb0 Mon Sep 17 00:00:00 2001 From: Saku Ytti Date: Wed, 24 Apr 2013 19:46:07 +0300 Subject: Remove Sequel model No point creating the model for one-off use, especially with dodgy dynamic consts --- lib/oxidized/source/sql.rb | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) (limited to 'lib') 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 -- cgit v1.2.1