Module: Nyanko::Invoker

Defined in:
lib/nyanko/invoker.rb,
lib/nyanko/invoker/options.rb,
lib/nyanko/invoker/function_finder.rb

Defined Under Namespace

Classes: FunctionFinder, Options

Instance Method Summary collapse

Dynamic Method Handling

This class handles dynamic methods through the method_missing method

#method_missing(method_name, *args, &block) ⇒ Object (private)



33
34
35
36
37
38
39
40
41
# File 'lib/nyanko/invoker.rb', line 33

def method_missing(method_name, *args, &block)
  if shared_method = __find_shared_method(method_name)
    instance_exec(*args, &shared_method)
  elsif args.empty? && __find_unit_local(method_name)
    __fetch_unit_local(method_name)
  else
    super
  end
end

Instance Method Details

#invoke(*args, &block) ⇒ Object



6
7
8
9
10
11
12
13
14
15
16
17
# File 'lib/nyanko/invoker.rb', line 6

def invoke(*args, &block)
  options = Options.new(*args)
  __with_default_stack(block) do
    __with_unit_locals_stack(options.locals) do
      if function = FunctionFinder.find(self, options)
        function.invoke(self, options.invoke_options)
      else
        run_default
      end
    end
  end
end

#run_defaultObject



27
28
29
# File 'lib/nyanko/invoker.rb', line 27

def run_default
  __invoke_default_block if __has_default_block?
end

#unitsObject



19
20
21
# File 'lib/nyanko/invoker.rb', line 19

def units
  @units ||= []
end

#view?Boolean

Returns:

  • (Boolean)


23
24
25
# File 'lib/nyanko/invoker.rb', line 23

def view?
  is_a?(ActionView::Base)
end