Module Qpid::Proton::Util::Constants
In: lib/util/constants.rb

Provides a means for defining constant values within the namespace of a class.

If the class has defined the class method, :post_add_constant, then that method will be invoked after each new item is added. It must be defined before any constants are defined.

Example

  class GrammarComponent

    include Qpid::Proton::Constants

    def self.post_add_constant(key, value)
      @terminal << value if value.terminal?
      @nonterminal << value if !value.terminal? && !value.rule
      @rule << value if value.rule
    end

    self.add_constant :LEFT_PARENTHESIS, new GrammarComponent("(", :terminal)
    self.add_constant :RIGHT_PARENTHESIS, new GrammarComponent(")", :terminal)
    self.add_constant :ELEMENT, new GrammarComponent("E", :rule)

    def initialize(component, type)
      @component = component
      @type = type
    end

    def terminal?; @type == :terminal; end

    def rule?; @type == :rule; end

  end

@private

Methods

included  

Classes and Modules

Module Qpid::Proton::Util::Constants::ClassMethods

Public Class methods

[Validate]