class Banter::Context
Public Class Methods
clear!()
click to toggle source
# File lib/banter/context.rb, line 48 def self.clear! Thread.current['pubsub_context'] = nil end
from_json(data_hash)
click to toggle source
# File lib/banter/context.rb, line 65 def self.from_json(data_hash) ::Banter::Context.new(data_hash) end
instance()
click to toggle source
# File lib/banter/context.rb, line 40 def self.instance Thread.current['pubsub_context'] || {} end
new(params_hash = {})
click to toggle source
acceptable values employee - employee id that the context could have user_id
- ender user id of call unique_id
- unique identifier (could be request.uuid most of the time) orig_ip_address - ip address of originating requester
# File lib/banter/context.rb, line 8 def initialize(params_hash = {}) @data = Hashie::Mash.new(params_hash) end
setup_context(attrs = {})
click to toggle source
# File lib/banter/context.rb, line 44 def self.setup_context(attrs = {}) Thread.current['pubsub_context'] = self.new(attrs) end
Public Instance Methods
application()
click to toggle source
# File lib/banter/context.rb, line 36 def application @data.application end
as_json()
click to toggle source
# File lib/banter/context.rb, line 20 def as_json @data.as_json end
employee_id()
click to toggle source
# File lib/banter/context.rb, line 16 def employee_id @data.employee_id end
method_missing(method_name, *arguments, &block)
click to toggle source
USE AS INFREQUENTLY AS POSSIBLE. Only use it if you absolutely must as really, we want context in the object, and not the kitchen sink, which is what this will turn out to be if we use regularly use this mechanism.
Calls superclass method
# File lib/banter/context.rb, line 56 def method_missing(method_name, *arguments, &block) if @data.key?(method_name) @data[method_name] else super end end
originating_ip_address()
click to toggle source
# File lib/banter/context.rb, line 28 def originating_ip_address @data.orig_ip_address end
serialize()
click to toggle source
# File lib/banter/context.rb, line 32 def serialize @data.as_json end
unique_id()
click to toggle source
# File lib/banter/context.rb, line 24 def unique_id @data.unique_id end
user_id()
click to toggle source
# File lib/banter/context.rb, line 12 def user_id @data.user_id end