Class: ConnectClient::Event
- Inherits:
-
Object
- Object
- ConnectClient::Event
- Defined in:
- lib/connect_client/event.rb
Constant Summary collapse
- @@RESERVED_PROPERTY_REGEX =
/tp_.+/i
Instance Attribute Summary collapse
-
#data ⇒ Object
readonly
Returns the value of attribute data.
Instance Method Summary collapse
-
#initialize(data) ⇒ Event
constructor
A new instance of Event.
- #to_json(options = nil) ⇒ Object
- #to_s ⇒ Object
- #validate ⇒ Object
Constructor Details
#initialize(data) ⇒ Event
Returns a new instance of Event.
12 13 14 15 16 |
# File 'lib/connect_client/event.rb', line 12 def initialize(data) event_data_defaults = { id: SecureRandom.uuid, timestamp: Time.now } @data = map_iso_dates event_data_defaults.merge(data) validate end |
Instance Attribute Details
#data ⇒ Object (readonly)
Returns the value of attribute data.
10 11 12 |
# File 'lib/connect_client/event.rb', line 10 def data @data end |
Instance Method Details
#to_json(options = nil) ⇒ Object
24 25 26 |
# File 'lib/connect_client/event.rb', line 24 def to_json( = nil) @data.to_json end |
#to_s ⇒ Object
28 29 30 |
# File 'lib/connect_client/event.rb', line 28 def to_s "Event Data: #{@data}" end |
#validate ⇒ Object
18 19 20 21 22 |
# File 'lib/connect_client/event.rb', line 18 def validate invalid_properties = @data.keys.grep(@@RESERVED_PROPERTY_REGEX) raise EventDataValidationError.new(invalid_properties) if invalid_properties.any? end |