Class: ActivityStream::Context
- Inherits:
-
Object
- Object
- ActivityStream::Context
- Defined in:
- lib/activity_stream.rb
Instance Attribute Summary collapse
-
#attributes ⇒ Object
readonly
Returns the value of attribute attributes.
Instance Method Summary collapse
- #call(&block) ⇒ Object
-
#initialize(attributes = {}) ⇒ Context
constructor
A new instance of Context.
- #to_s ⇒ Object
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
#attributes ⇒ Object (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
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_s ⇒ Object
21 22 23 |
# File 'lib/activity_stream.rb', line 21 def to_s attributes[:context].to_s end |