module Druid::JavascriptFrameworkFacade

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

Public Class Methods

add_framework(key, value) click to toggle source
# File lib/druid/javascript_framework_facade.rb, line 31
def add_framework(key, value)
  raise invalid_framework unless value.respond_to? :pending_requests
  initialize_script_builder unless @builder
  @builder[key] = value
end
framework() click to toggle source

Get the framework that will be used

# File lib/druid/javascript_framework_facade.rb, line 40
def framework
  @framework
end
framework=(framework) click to toggle source

Set the framework to use

@param [Symbol] the framework to use. :jquery and :prototype, :yui, and :angularjs are supported

# File lib/druid/javascript_framework_facade.rb, line 25
def framework=(framework)
  initialize_script_builder unless @builder
  raise unknown_framework(framework) unless @builder[framework]
  @framework = framework
end
pending_requests() click to toggle source

get the javascript to determine number of pending requests

# File lib/druid/javascript_framework_facade.rb, line 52
def pending_requests
  script_builder.pending_requests
end
script_builder() click to toggle source
# File lib/druid/javascript_framework_facade.rb, line 44
def script_builder
  initialize_script_builder unless @builder
  @builder[@framework]
end

Private Class Methods

initialize_script_builder() click to toggle source
# File lib/druid/javascript_framework_facade.rb, line 58
def initialize_script_builder
  @builder = {
    :jquery => Druid::Javascript::JQuery,
    :prototype => Druid::Javascript::Prototype,
    :yui => Druid::Javascript::YUI,
    :angularjs => Druid::Javascript::AngularJS
  }
end
invalid_framework() click to toggle source
# File lib/druid/javascript_framework_facade.rb, line 71
def invalid_framework
  "The Javascript framework you provided does not implement the necessary methods"
end
unknown_framework(framework) click to toggle source
# File lib/druid/javascript_framework_facade.rb, line 67
def unknown_framework(framework)
  "You specified the Javascript framework #{framework} and it is unknown to the system"
end