Sha256: 5f4838f0665995134c1eec9021e5859003ff91a1eb47bad4439e662846b4b8bb

Contents?: true

Size: 820 Bytes

Versions: 6

Compression:

Stored size: 820 Bytes

Contents

module ReactiveRuby
  class ComponentLoader
    attr_reader :v8_context
    private :v8_context

    def initialize(v8_context)
      @v8_context = v8_context
    end

    def load(file = components)
      return true if loaded?
      !!v8_context.eval(opal(file))
    end

    def load!(file = components)
      return true if loaded?
      self.load(file)
    ensure
      raise "No react.rb components found in #{components}.rb" unless loaded?
    end

    def loaded?
      !!v8_context.eval('Opal.React')
    end

    private

    def components
      # Make this configurable at some point
      'components'
    end

    def opal(file)
      Opal::Processor.load_asset_code(assets, file)
    rescue # What exception is being caught here?
    end

    def assets
      ::Rails.application.assets
    end
  end
end

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
reactive-ruby-0.7.31 lib/reactive-ruby/component_loader.rb
reactive-ruby-0.7.30 lib/reactive-ruby/component_loader.rb
reactive-ruby-0.7.29 lib/reactive-ruby/component_loader.rb
reactive-ruby-0.7.28 lib/reactive-ruby/component_loader.rb
reactive-ruby-0.7.27 lib/reactive-ruby/component_loader.rb
reactive-ruby-0.7.26 lib/reactive-ruby/component_loader.rb