Class: Canned::Context::Base

Inherits:
Object
  • Object
show all
Defined in:
lib/canned/context/base.rb

Overview

Base class for other context types

Direct Known Subclasses

Actor, Default, Multi, Resource

Instance Method Summary collapse

Constructor Details

#initialize(_ctx, _ext, _stack) ⇒ Base

Returns a new instance of Base.



8
9
10
11
12
# File 'lib/canned/context/base.rb', line 8

def initialize(_ctx, _ext, _stack)
  @ctx = _ctx
  @ext = _ext
  @stack = _stack
end

Dynamic Method Handling

This class handles dynamic methods through the method_missing method

#method_missing(_method, *_args, &_block) ⇒ Object

The method missing callback is used to hook extensions provided by context.



15
16
17
18
19
# File 'lib/canned/context/base.rb', line 15

def method_missing(_method, *_args, &_block)
  ext = @ext[_method]
  return super if ext.nil?
  instance_exec(*_args, &exc)
end

Instance Method Details

#indeed?Boolean

 Returns true if context is in a “loaded” state

Returns:

  • (Boolean)


22
23
24
# File 'lib/canned/context/base.rb', line 22

def indeed?
  return @stack != false
end