I am looking at a ruby script and testing it... I don''t fully understand the following line of code : database = YAML::load_file("config/#{fetch(:db_file, ''database.yml'')}") => fetch(:db_file, ''database.yml'') ... what''s is this function fetch() ? I know the fetch(key, *extras) in ActiveSupport, but this is not the case.... any suggestion ? thanks -- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
Is this part of a capistrano script? <https://github.com/capistrano/capistrano/wiki/2.x-DSL-Configuration-Variables-Fetch>If so then it uses the value in deploy.rb where set :db_file is defined. (Perhaps look here: https://github.com/leehambley/capistrano-handbook/blob/master/index.markdown ) Otherwise I would imply you should give some more information about the type of script you are looking at. On 02/02/11 15:22, Erwin wrote:> I am looking at a ruby script and testing it... > I don''t fully understand the following line of code : > > database = YAML::load_file("config/#{fetch(:db_file, > ''database.yml'')}") > > => fetch(:db_file, ''database.yml'') ... what''s is this function > fetch() ? > > I know the fetch(key, *extras) in ActiveSupport, but this is not the > case.... any suggestion ? > > thanks >-- best regards Bente Pieck -- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
Thanks , you''re right, :db_file is defined, and the line runs well... my concern was about the ''fetch'' function which returns a string.. it seems to return the second string argument if the first is not defined ... but is it a Ruby function or a Rails function .... I know a anArray.fetch( aString) but not this one .... On 2 fév, 16:07, Bente Pieck <bente.pi...-ncST9ati83jjhi9iKp3Nug@public.gmane.org> wrote:> Is this part of a capistrano script? > > <https://github.com/capistrano/capistrano/wiki/2.x-DSL-Configuration-V...>If > so then it uses the value in deploy.rb where > set :db_file > is defined. > > (Perhaps look here:https://github.com/leehambley/capistrano-handbook/blob/master/index.m... > ) > > Otherwise I would imply you should give some more information about the > type of script you are looking at. > > On 02/02/11 15:22, Erwin wrote: > > > I am looking at a ruby script and testing it... > > I don''t fully understand the following line of code : > > > database = YAML::load_file("config/#{fetch(:db_file, > > ''database.yml'')}") > > > => fetch(:db_file, ''database.yml'') ... what''s is this function > > fetch() ? > > > I know the fetch(key, *extras) in ActiveSupport, but this is not the > > case.... any suggestion ? > > > thanks > > -- > best regards > Bente Pieck-- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe@googlegroups.com. For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
Bente Pieck
2011-Feb-03 07:24 UTC
Re: Re: is this line of code right in Ruby 1.9.2 / Rails 3
I told you: it is a method of capistrano. set sets the value, fetch gets it Follow my first link and read the chapter "Variables" ... Or look here https://github.com/capistrano/capistrano/wiki/2.x-DSL-Configuration-Variables-Fetch Or look here https://github.com/capistrano/capistrano/blob/master/lib/capistrano/configuration/variables.rb On 02/02/11 17:57, Erwin wrote:> Thanks , you''re right, :db_file is defined, and the line runs well... > my concern was about the ''fetch'' function which returns a string.. > it seems to return the second string argument if the first is not > defined ... > but is it a Ruby function or a Rails function .... > I know a anArray.fetch( aString) but not this one .... > > On 2 fév, 16:07, Bente Pieck<bente.pi...-ncST9ati83jjhi9iKp3Nug@public.gmane.org> wrote: >> Is this part of a capistrano script? >> >> <https://github.com/capistrano/capistrano/wiki/2.x-DSL-Configuration-V...>If >> so then it uses the value in deploy.rb where >> set :db_file >> is defined. >> >> (Perhaps look here:https://github.com/leehambley/capistrano-handbook/blob/master/index.m... >> ) >> >> Otherwise I would imply you should give some more information about the >> type of script you are looking at. >> >> On 02/02/11 15:22, Erwin wrote: >> >>> I am looking at a ruby script and testing it... >>> I don''t fully understand the following line of code : >>> database = YAML::load_file("config/#{fetch(:db_file, >>> ''database.yml'')}") >>> => fetch(:db_file, ''database.yml'') ... what''s is this function >>> fetch() ? >>> I know the fetch(key, *extras) in ActiveSupport, but this is not the >>> case.... any suggestion ? >>> thanks >> -- >> best regards >> Bente Pieck-- best regards Bente Pieck -- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe@googlegroups.com. For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.