Module: Qpid::Proton::Util::SwigHelper

Included in:
Connection, Delivery, Disposition, Link, Reactor::Reactor, Receiver, SSL, Selectable, Session, Terminus, Transport
Defined in:
lib/util/swig_helper.rb

Overview

Provides helper functions for writing wrapper functions for the underlying C APIs.

Before defining any mutators the class must define the name of the prefix for methods with the constant PROTON_METOD_PREFIX.

Mutators, Setters And Getters

There are three types of wrappers that are supported:

proton_writer

Defines a set-only method for the named attribute.

proton_reader

Defines a get-only method for the named attribute.

proton_accessor

Defines both a set- and a get-method for the named

attribute.
proton_caller

A simple wrapper for calling an underlying method,

avoids repetitive boiler plate coding.

Arguments

:is_or_get => :get

For both the getter and the mutator types

you can also declare that the method uses “is” instead of “get” in the underlying API. Such methods are then defined with “?”

Examples:

class Terminus

  include WrapperHelper

  PROTON_METHOD_PREFIX = "pn_terminus"

  # add methods "type" and "type=" that call "pn_terminus_{get,set}_type"
  proton_accessor :type

  # adds the method "dynamic?" that calls "pn_terminus_is_dynamic"
  proton_accessor :dynamic, :is_or_get => :is

  # adds a method named "foo" that calls "pn_terminus_foo"
  proton_caller :foo

end

Defined Under Namespace

Modules: ClassMethods

Class Method Summary collapse

Class Method Details

.included(base) ⇒ Object



66
67
68
# File 'lib/util/swig_helper.rb', line 66

def self.included(base)
  base.extend ClassMethods
end