lib/hyperloop-config.rb in hyperloop-config-0.8.1 vs lib/hyperloop-config.rb in hyperloop-config-0.9.0

- old
+ new

@@ -1,49 +1,20 @@ -module Hyperloop - # configuration utility - class << self - - def initialized_blocks - @initialized_blocks ||= [] - end - - def reset_blocks - @reset_blocks ||= [] - end - - def configuration - reset_blocks.each(&:call) - yield self - initialized_blocks.each(&:call) - end - - def define_setting(name, default = nil, &block) - class_variable_set("@@#{name}", default) - - define_class_method "#{name}=" do |value| - class_variable_set("@@#{name}", value) - block.call value if block - value - end - - define_class_method name do - class_variable_get("@@#{name}") - end - end - - def on_config_reset &block - reset_blocks << block - end - - def on_config_initialized &block - initialized_blocks << block - end - - private - - def define_class_method(name, &block) - (class << self; self; end).instance_eval do - define_method name, &block - end - end - end +if RUBY_ENGINE == 'opal' + require 'hyperloop/client_stubs' + require 'hyperloop/on_client' +else + require 'opal' + require 'hyperloop/config_settings' + require 'hyperloop/requires' + require 'hyperloop/client_readers' + require 'hyperloop/on_client' + require 'hyperloop/rail_tie' if defined? Rails + Hyperloop.require 'opal', gem: true + Hyperloop.require 'hyperloop-config', gem: true + # class Sprockets::DirectiveProcessor + # def process_depend_on_config_directive(file) + # path = File.expand_path(file, "#{Rails.root}/config") + # resolve(path) + # end + # end + Opal.append_path(File.expand_path('../', __FILE__).untaint) end