require 'securerandom' require 'json' module FlydataCore module Event class FlydataEvent attr_accessor :noun attr_accessor :verb attr_accessor :data attr_accessor :id attr_accessor :created attr_accessor :data_entry_id attr_accessor :data_port_id def initialize (noun, verb, data=nil, de_id=nil,dp_id=nil, id=nil, timestamp=nil) @noun = noun @verb = verb @data_entry_id = de_id @data_port_id = dp_id @data = data @id = id.nil? ? SecureRandom.uuid: id @created = timestamp.nil? ? Time.now : timestamp end def to_json {:noun => @noun, :verb => @verb, :data_entry_id=>@data_entry_id, :data_port_id=> @data_port_id, id => @id, :created => @created, :data => @data}.to_json end end end end