Module: Druid::JavascriptFrameworkFacade

Defined in:
lib/druid/javascript_framework_facade.rb

Overview

Provide hooks into different common Javascript Frameworks. Currently this module only supports jQuery and Prototype but it has ability for you to plug your own framework into it and therefore have it work with this gem. You do this by calling the #add_framework method. The module you provide must implement the necessary methods. Please look at the jQuery or Prototype implementations to determine the necessary methods

Class Method Summary collapse

Class Method Details

.add_framework(key, value) ⇒ Object



30
31
32
33
34
# File 'lib/druid/javascript_framework_facade.rb', line 30

def add_framework(key, value)
  raise invalid_framework unless value.respond_to? :pending_requests
  initialize_script_builder unless @builder
  @builder[key] = value
end

.frameworkObject

Get the framework that will be used



39
40
41
# File 'lib/druid/javascript_framework_facade.rb', line 39

def framework
  @framework
end

.framework=(framework) ⇒ Object

Set the framework to use

are supported

Parameters:

  • the (Symbol)

    framework to use. :jquery and :prototype



24
25
26
27
28
# File 'lib/druid/javascript_framework_facade.rb', line 24

def framework=(framework)
  initialize_script_builder unless @builder
  raise unknown_framework(framework) unless @builder[framework]
  @framework = framework
end

.pending_requestsObject

get the javascript to determine number of pending requests



51
52
53
# File 'lib/druid/javascript_framework_facade.rb', line 51

def pending_requests
  script_builder.pending_requests
end

.script_builderObject



43
44
45
46
# File 'lib/druid/javascript_framework_facade.rb', line 43

def script_builder
  initialize_script_builder unless @builder
  @builder[@framework]
end