Skip to content

Instantly share code, notes, and snippets.

@julesfern
Created May 28, 2009 15:08
Show Gist options
  • Select an option

  • Save julesfern/119373 to your computer and use it in GitHub Desktop.

Select an option

Save julesfern/119373 to your computer and use it in GitHub Desktop.
Configurable is a mixin intended for internal use within the SDK.
It provides a suite of helper methods to objects that use the scoped configuration
system within the root Videojuicer module.
Objects that are Configurable have a local configuration, which will always be
respected, and a shared configuration object which merges the current configuration
scope with the local configuration.
For instance:
# Assuming that the Videojuicer default configuration is a simple hash containing {:in_a_scope=>false}
a_configurable.configure! :foo=>"bar" # config[:foo] will ALWAYS == "bar" for this object.
a_configurable.local_config #=> {:foo=>"bar"}
a_configurable.config #=> {:in_a_scope=>false, :foo=>"bar"}
# Now let's enter a scope:
Videojuicer.enter_scope :in_a_scope=>true, :foo=>"not bar"
a_configurable.local_config #=> {:foo=>"bar"}
a_configurable.config #=> {:in_a_scope=>true, :foo=>"bar"}
# And leave it again..
Videojuicer.exit_scope
a_configurable.local_config #=> {:foo=>"bar"}
a_configurable.config #=> {:in_a_scope=>false, :foo=>"bar"}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment