On Oct 11, 5:48 am, Michael Lang <[email protected]> wrote:
> Hello,
>
> I'm trying to set up an ETL process to load some data from various
> data sources into a data warehouse oriented database using Sequel.
> I'm trying to dynamically construct the DB.create_table! block, but
> the "field_defs" variable I have is out of scope and I can't access it
> within the create table block.
>
> Any suggestion how I can do this?
>
> DB.create_table!(table) do
>   primary_key :id
>   field_defs.each do |field_def|
>     column(field_def["field_name"], field_def["type"], :index =>
> field_def["indexed"])
>   end
> end

I'm not sure what you mean by "out of scope", but I assume you mean
it's a method and not a local variable, in which case you just need to
assign it to a local variable outside the block:

  fds = field_defs
  DB.create_table!(table) do
    primary_key :id
    fds.each do |fd|
      column(fd["field_name"], fd["type"], :index => fd["indexed"])
    end
  end

Jeremy

-- 
You received this message because you are subscribed to the Google Groups 
"sequel-talk" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/sequel-talk?hl=en.

Reply via email to