Class: Ferro::Document

Inherits:
Object
  • Object
show all
Includes:
Elementary
Defined in:
opal/opal-ferro/ferro_document.js.rb

Overview

This is the entry point for any Ferro application. It represents the top level object of the Master Object Model (MOM). There should be only one class that inhertits from FerroDocument in an application. This class attaches itself to the DOM ‘document.body` object. Any existing child nodes of `document.body` are removed.

Constant Summary

Constants included from Elementary

Elementary::RESERVED_NAMES

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods included from Elementary

#_after_create, #_before_create, #_stylize, #add_child, #after_create, #before_create, #cascade, #create, #creation, #destroy, #each_child, #forget_children, #method_missing, #remove_child, #style, #symbolize

Constructor Details

#initializeDocument

Create the document and start the creation process (casading).



19
20
21
22
23
24
# File 'opal/opal-ferro/ferro_document.js.rb', line 19

def initialize
  @compositor = nil
  @sym        = :document
  @children   = {}
  creation
end

Dynamic Method Handling

This class handles dynamic methods through the method_missing method in the class Ferro::Elementary

Instance Attribute Details

#childrenObject (readonly)

Returns the value of attribute children.



15
16
17
# File 'opal/opal-ferro/ferro_document.js.rb', line 15

def children
  @children
end

#compositorObject (readonly)

Returns the value of attribute compositor.



15
16
17
# File 'opal/opal-ferro/ferro_document.js.rb', line 15

def compositor
  @compositor
end

#symObject (readonly)

Returns the value of attribute sym.



15
16
17
# File 'opal/opal-ferro/ferro_document.js.rb', line 15

def sym
  @sym
end

Instance Method Details

#componentObject

The document class is a component.



47
48
49
# File 'opal/opal-ferro/ferro_document.js.rb', line 47

def component
  self
end

#domtypeObject

Returns the domtype of the document instance.



52
53
54
# File 'opal/opal-ferro/ferro_document.js.rb', line 52

def domtype
  :body
end

#elementObject

Returns the DOM element.



32
33
34
# File 'opal/opal-ferro/ferro_document.js.rb', line 32

def element
  factory.body
end

#factoryObject

Returns the one and only instance of the factory.



37
38
39
# File 'opal/opal-ferro/ferro_document.js.rb', line 37

def factory
  @factory ||= Factory.new(self, @compositor)
end

#page404(pathname) ⇒ Object

Callback for the router when no matching routes can be found. Override this method to add custom behavior.

Parameters:

  • pathname (String)

    The route that was not matched by the router



76
# File 'opal/opal-ferro/ferro_document.js.rb', line 76

def page404(pathname);end

#parentObject

The document doesn’t have a parent so returns itself.



27
28
29
# File 'opal/opal-ferro/ferro_document.js.rb', line 27

def parent
  self
end

#rootObject

The document class is the root element.



42
43
44
# File 'opal/opal-ferro/ferro_document.js.rb', line 42

def root
  self
end

#routerObject

Returns the one and only instance of the router.



66
67
68
# File 'opal/opal-ferro/ferro_document.js.rb', line 66

def router
  @router ||= Router.new(method(:page404))
end

#switch_compositor_theme(theme) ⇒ Object

Switch to a new theme for the compositor, this will remove/add CSS classes for all elements as needed.

param [Symbol] theme The new theme name



61
62
63
# File 'opal/opal-ferro/ferro_document.js.rb', line 61

def switch_compositor_theme(theme)
  @compositor.switch_theme(self, theme) if @compositor
end