Class: Kanal::Plugins::BatteriesBridge::Bridges::Bridge

Inherits:
Object
  • Object
show all
Includes:
Core::Logging::Logger
Defined in:
lib/kanal/plugins/batteries_bridge/bridges/bridge.rb

Overview

Base class for bridges. All bridges should be derived from this class

Direct Known Subclasses

TelegramBridge

Defined Under Namespace

Classes: ParamConverter

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeBridge

Returns a new instance of Bridge.



22
23
24
25
26
27
28
# File 'lib/kanal/plugins/batteries_bridge/bridges/bridge.rb', line 22

def initialize
  @core_hooks = nil
  @source = nil
  @input_converters = []
  @output_converters = []
  @fail_gracefully = true
end

Instance Attribute Details

#fail_gracefully=(value) ⇒ Object (writeonly)

Sets the attribute fail_gracefully

Parameters:

  • value

    the value to set the attribute fail_gracefully to.



17
18
19
# File 'lib/kanal/plugins/batteries_bridge/bridges/bridge.rb', line 17

def fail_gracefully=(value)
  @fail_gracefully = value
end

Instance Method Details

#input_convert(from_param, to_param, &block) ⇒ void

This method returns an undefined value.

Register input converter

Parameters:

  • from_param (Symbol)

    which input parameter will be used for getting value

  • to_param (Symbol)

    which input parameter will be populated with return value from block

  • &block (Proc)

    block will receive value from parameter defined in from_param argument, returned value will be used for new parameter value



61
62
63
# File 'lib/kanal/plugins/batteries_bridge/bridges/bridge.rb', line 61

def input_convert(from_param, to_param, &block)
  @input_converters << ParamConverter.new(from_param, to_param, block)
end

#output_convert(from_param, to_param, &block) ⇒ void

This method returns an undefined value.

See #input_convert

Parameters:

  • from_param (Symbol)

    <description>

  • to_param (Symbol)

    <description>

  • &block (Proc)

    <description>



74
75
76
# File 'lib/kanal/plugins/batteries_bridge/bridges/bridge.rb', line 74

def output_convert(from_param, to_param, &block)
  @output_converters << ParamConverter.new(from_param, to_param, block)
end

#require_source(source) ⇒ void

This method returns an undefined value.

:source input parameter will be checked for this

Parameters:

  • source (Symbol)

    <description>



48
49
50
# File 'lib/kanal/plugins/batteries_bridge/bridges/bridge.rb', line 48

def require_source(source)
  @source = source
end

#setupvoid

This method returns an undefined value.

Required for overriding method in the derived bridge classes

Raises:

  • (NotImplementedError)


35
36
37
# File 'lib/kanal/plugins/batteries_bridge/bridges/bridge.rb', line 35

def setup
  raise NotImplementedError
end