Class: ActivityStream::Context

Inherits:
Object
  • Object
show all
Defined in:
lib/activity_stream.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(attributes = {}) ⇒ Context

Returns a new instance of Context.



7
8
9
# File 'lib/activity_stream.rb', line 7

def initialize(attributes = {})
  @attributes = attributes
end

Instance Attribute Details

#attributesObject (readonly)

Returns the value of attribute attributes.



5
6
7
# File 'lib/activity_stream.rb', line 5

def attributes
  @attributes
end

Instance Method Details

#call(&block) ⇒ Object

Raises:

  • (ArgumentError)


11
12
13
14
15
16
17
18
19
# File 'lib/activity_stream.rb', line 11

def call(&block)
  raise ArgumentError unless block_given?
  current_context = Thread.current[:activity_stream_context]
  Thread.current[:activity_stream_context] = self
  
  yield
  
  Thread.current[:activity_stream_context] = current_context
end

#to_sObject



21
22
23
# File 'lib/activity_stream.rb', line 21

def to_s
  attributes[:context].to_s
end