Sha256: 83b84709baaf4fbf8b9fa47ae0647e5654d8e9864200dfe827a007b1c8c4e743
Contents?: true
Size: 1.99 KB
Versions: 6
Compression:
Stored size: 1.99 KB
Contents
require 'volt/volt/environment' require 'volt/extra_core/extra_core' require 'volt/reactive/computation' require 'volt/reactive/dependency' require 'volt/utils/modes' require 'volt/utils/volt_user_error' require 'volt/utils/boolean_patch' require 'volt/utils/time_patch' require 'volt/utils/time_opal_patch' if RUBY_PLATFORM == 'opal' require 'volt/config' require 'volt/data_stores/data_store' unless RUBY_PLATFORM == 'opal' require 'volt/volt/users' module Volt @in_browser = if RUBY_PLATFORM == 'opal' # When testing with opal-rspec, it technically is in a browser # but its not setup with our own app code. `!!document && !window.OPAL_SPEC_PHANTOM && window.$` else false end include Modes class << self def root fail 'Volt.root can not be called from the client.' if self.client? @root ||= File.expand_path(Dir.pwd) end attr_writer :root def server? !!ENV['SERVER'] end def client? !ENV['SERVER'] end if RUBY_PLATFORM != 'opal' def console? !!ENV['CONSOLE'] end def source_maps? if !ENV['MAPS'] # If no MAPS is specified, enable it in dev Volt.env.development? else ENV['MAPS'] != 'false' end end end def env @env ||= Volt::Environment.new end def logger @logger ||= Volt::VoltLogger.new end attr_writer :logger def in_browser? @in_browser end # When we use something like a Task, we don't specify an app, so we use # a thread local or global to lookup the current app. This lets us run # more than one app at once, giving deference to a global app. def current_app Thread.current['volt_app'] || $volt_app end # Runs code in the context of this app. def in_app previous_app = Thread.current['volt_app'] Thread.current['volt_app'] = self begin yield ensure Thread.current['volt_app'] = previous_app end end end end
Version data entries
6 entries across 6 versions & 1 rubygems
Version | Path |
---|---|
volt-0.9.7.pre8 | lib/volt.rb |
volt-0.9.7.pre7 | lib/volt.rb |
volt-0.9.7.pre6 | lib/volt.rb |
volt-0.9.7.pre5 | lib/volt.rb |
volt-0.9.7.pre3 | lib/volt.rb |
volt-0.9.7.pre2 | lib/volt.rb |