class Onuro::ContextBuilder

Builder class that allows to create a builder pattern for easily creation of the Onuro::Context containing attributes to help you in the event rule processing @see Onuro::Context

Attributes

context[RW]

Public Class Methods

build() { |builder| ... } click to toggle source

Class method that uses the builder pattern in order to easy create an Onuro::Context instance and being populated

@Example

ContextBuilder.build do |builder|
  builder.add(:member_id, 12)
end

@see Onuro::Context

# File lib/onuro/context_builder.rb, line 38
def self.build
  builder = new
  yield builder if block_given?
  builder.context
end
new() click to toggle source

Creates a new instance of Onuro::ContextBuilder with its Onuro::Context attribute set to default values.

@see Onuro::Context

# File lib/onuro/context_builder.rb, line 15
def initialize
  self.context = Context.new
end

Public Instance Methods

add(key, value) click to toggle source

Adds a key/value item in the Onuro::Context

@Example

ContextBuilder.new.add(:member_id, 12)

@see Onuro::Context

# File lib/onuro/context_builder.rb, line 25
def add(key, value)
  context.add(key, value)
end