Class: Segment::Analytics::Message
- Inherits:
-
Object
- Object
- Segment::Analytics::Message
- Defined in:
- lib/segment/analytics/message.rb
Overview
Represents a message to be sent to the API
Instance Method Summary collapse
-
#initialize(hash) ⇒ Message
constructor
A new instance of Message.
- #json_size ⇒ Object
-
#to_json(*args) ⇒ Object
Since the hash is expected to not be modified (set at initialization), the JSON version can be cached after the first computation.
- #too_big? ⇒ Boolean
Constructor Details
#initialize(hash) ⇒ Message
Returns a new instance of Message.
7 8 9 |
# File 'lib/segment/analytics/message.rb', line 7 def initialize(hash) @hash = hash end |
Instance Method Details
#json_size ⇒ Object
15 16 17 |
# File 'lib/segment/analytics/message.rb', line 15 def json_size to_json.bytesize end |
#to_json(*args) ⇒ Object
Since the hash is expected to not be modified (set at initialization), the JSON version can be cached after the first computation.
21 22 23 |
# File 'lib/segment/analytics/message.rb', line 21 def to_json(*args) @json ||= @hash.to_json(*args) end |