Class: Ovto::WiredActions

Inherits:
Object
  • Object
show all
Defined in:
lib/ovto/wired_actions.rb

Instance Method Summary collapse

Constructor Details

#initialize(actions, app, runtime, parent) ⇒ WiredActions

Create a WiredActions

  • actions: Ovto::Actions

  • app: Ovto::App

  • runtime: Ovto::Runtime (to call scheduleRender after state change)

  • parent: WiredActionSet



12
13
14
# File 'lib/ovto/wired_actions.rb', line 12

def initialize(actions, app, runtime, parent)
  @actions, @app, @runtime, @parent = actions, app, runtime, parent
end

Dynamic Method Handling

This class handles dynamic methods through the method_missing method

#method_missing(name, args_hash = {}) ⇒ Object

Raises:

  • (NoMethodError)


16
17
18
19
20
21
22
23
24
25
26
# File 'lib/ovto/wired_actions.rb', line 16

def method_missing(name, args_hash={})
  raise NoMethodError, "undefined method `#{name}' on #{self}" unless respond_to?(name)
  if @actions.respond_to?(name)
    Ovto.log_error {
      Ovto.debug_trace_log("invoke action \"#{name}\" on #{@actions.class}")
      invoke_action(name, args_hash)
    }
  else
    @parent[name][WiredActionSet::THE_MIDDLEWARE_ITSELF]  # WiredActions of a middleware named `name`
  end
end

Instance Method Details

#_appObject

internal



33
34
35
# File 'lib/ovto/wired_actions.rb', line 33

def _app
  @app
end

#respond_to?(name) ⇒ Boolean

Returns:

  • (Boolean)


28
29
30
# File 'lib/ovto/wired_actions.rb', line 28

def respond_to?(name)
  @actions.respond_to?(name) || @parent.middleware_names.include?(name)
end