lib/spinebox/config.rb in spinebox-0.0.1 vs lib/spinebox/config.rb in spinebox-0.0.2

- old
+ new

@@ -1,22 +1,47 @@ module Spinebox + module Config + + # Reset the config + def self.reset! + @@configuration = nil + end + reset! + + # Offer the configuration + def self.configuration(&block) + @@configuration ||= OpenStruct.new( + :assets => Sprockets::Environment.new, + :views => Sprockets::Environment.new + ) + + block.call(@@configuration) if block + @@configuration + end + + end + class << self # Offers the configuration with the assets def config - @@configuration ||= OpenStruct.new(:assets => Sprockets::Environment.new) - yield(@@configuration) if block_given? - @@configuration + block = Proc.new if block_given? + Config.configuration(&block) end # Straight access to the assets def assets config.assets end + # Straight access to the views + def views + config.views + end + # Load the config def load_config!(config = "./config/config.rb") - require config + load config end end end \ No newline at end of file