¿Cómo se implementa Spree.config?

I'm studying Spree's source code and I came across the snippet.

Spree.config do |config|
  # Example:
  # Uncomment to override the default site name.
  # config.site_name = "Spree Demo Site"
end

How is this being implemented? I cannot find Spree.config defined anywhere as a method. I'm guessing some meta-programming is involved.

preguntado el 31 de julio de 12 a las 10:07

1 Respuestas

Looks like it is defined in https://github.com/spree/spree/blob/master/core/lib/spree/core.rb (line 68 at this time).

config is a module method on the Spree module. It's implementation passes the Spree::Config object to the given block.

Respondido 31 Jul 12, 13:07

Thanks Steve. Does this mean that Spree::Config is just an arbitrary object? When I type Spree::Config into the console, it returns #<Spree::AppConfiguration:0x007f7f45d0ed98>. I don't see code that 'connects` Spree::Config y Spree::AppConfiguration. - Benjamín Tan Wei Hao

Parece como si Config is just a constant again in the Spree that gets set in github.com/spree/spree/blob/master/core/lib/spree/core/… (line 41) as part of the initialisation of the Rails engine. The AppConfiguration el objeto se crea en github.com/spree/spree/blob/master/core/lib/spree/core/… - Steve

No es la respuesta que estás buscando? Examinar otras preguntas etiquetadas or haz tu propia pregunta.