lib/spontaneous/plugins/application/state.rb in spontaneous-0.2.0.beta4 vs lib/spontaneous/plugins/application/state.rb in spontaneous-0.2.0.beta5

- old
+ new

@@ -22,10 +22,11 @@ logger.warn "Auto login is enabled and set to '#{site.config.auto_login}'.\n" \ " Please ensure this is disabled in production mode by removing the\n" \ " 'auto_login' setting from your environment file." end Thread.current[:spontaneous_loaded] = true + site end end # This is called after definition of the Content model. # @@ -37,31 +38,36 @@ # I could do the assignment of Spontaneous::Content automatically # after creation of the first content model, but this method provides # a nice way to create the ::Site constant in the user/site code def site(content_model) site!(content_model) unless defined?(Spontaneous::Content) - Spontaneous::Site + Spontaneous::Site.instance end # This forces the assignment of Spontaneous::Content, overwriting any # previous value. # # Used in tests. # def site!(content_model) - spot = ::Spontaneous - Spontaneous.send :remove_const, :Content if defined?(Spontaneous::Content) - Spontaneous.const_set(:Content, content_model) - Spontaneous::Site + site = Spontaneous::Site.instance + # Spontaneous.send :remove_const, :Content if defined?(Spontaneous::Content) + # Spontaneous.const_set(:Content, content_model) + site.model = content_model + site end def loaded? Thread.current[:spontaneous_loaded] end + def instance + Spontaneous::Site.instance + end + def config - Spontaneous::Site.instance.config + instance.config end def db_settings YAML.load_file(root / "config/database.yml")[environment] end