class Megam::EventsStorage
Public Class Methods
create(params)
click to toggle source
# File lib/megam/core/eventsstorage.rb, line 130 def self.create(params) evt = from_hash(params) evt.create end
from_hash(o)
click to toggle source
# File lib/megam/core/eventsstorage.rb, line 115 def self.from_hash(o) evt = self.new(o) evt.from_hash(o) evt end
index(params)
click to toggle source
# File lib/megam/core/eventsstorage.rb, line 146 def self.index(params) asm = self.new(params) asm.megam_rest.index_eventsstorage end
json_create(o)
click to toggle source
# File lib/megam/core/eventsstorage.rb, line 101 def self.json_create(o) evt = new({}) evt.account_id(o["account_id"]) if o.has_key?("account_id") evt.event_type(o["event_type"]) if o.has_key?("event_type") #this will be an array? can hash store array? evt.data(o["data"]) if o.has_key?("data") evt.limit(o["limit"]) if o.has_key?("limit") evt.created_at(o["created_at"]) if o.has_key?("created_at") evt.some_msg[:code] = o["code"] if o.has_key?("code") evt.some_msg[:msg_type] = o["msg_type"] if o.has_key?("msg_type") evt.some_msg[:msg]= o["msg"] if o.has_key?("msg") evt.some_msg[:links] = o["links"] if o.has_key?("links") evt end
list(params)
click to toggle source
Load a account by email_p
# File lib/megam/core/eventsstorage.rb, line 141 def self.list(params) asm = self.new(params) asm.megam_rest.list_eventsstorage(params[:limit]) end
new(o)
click to toggle source
Calls superclass method
Megam::RestAdapter::new
# File lib/megam/core/eventsstorage.rb, line 3 def initialize(o) @account_id = nil @event_type = nil @data = [] @created_at = nil @limit = nil @some_msg = {} super(o) end
Public Instance Methods
account_id(arg=nil)
click to toggle source
# File lib/megam/core/eventsstorage.rb, line 17 def account_id(arg=nil) if arg != nil @account_id = arg else @account_id end end
create()
click to toggle source
Create the node via the REST API
# File lib/megam/core/eventsstorage.rb, line 136 def create megam_rest.post_events(to_hash) end
created_at(arg=nil)
click to toggle source
# File lib/megam/core/eventsstorage.rb, line 49 def created_at(arg=nil) if arg != nil @created_at = arg else @created_at end end
data(arg=[])
click to toggle source
# File lib/megam/core/eventsstorage.rb, line 33 def data(arg=[]) if arg != [] @data = arg else @data end end
error?()
click to toggle source
# File lib/megam/core/eventsstorage.rb, line 57 def error? crocked = true if (some_msg.has_key?(:msg_type) && some_msg[:msg_type] == "error") end
event_type(arg=nil)
click to toggle source
# File lib/megam/core/eventsstorage.rb, line 25 def event_type(arg=nil) if arg != nil @event_type = arg else @event_type end end
eventsstorage()
click to toggle source
# File lib/megam/core/eventsstorage.rb, line 13 def eventsstorage self end
for_json()
click to toggle source
# File lib/megam/core/eventsstorage.rb, line 90 def for_json result = { "account_id" => account_id, "event_type" => event_type, "data" => data, "limit" => limit, "created_at" => created_at } result end
from_hash(o)
click to toggle source
# File lib/megam/core/eventsstorage.rb, line 121 def from_hash(o) @account_id = o[:account_id] if o.has_key?(:account_id) @event_type = o[:event_type] if o.has_key?(:event_type) @data = o[:data] if o.has_key?(:data) @limit = o[:limit] if o.has_key?(:limit) @created_at = o[:created_at] if o.has_key?(:created_at) self end
limit(arg=[])
click to toggle source
# File lib/megam/core/eventsstorage.rb, line 41 def limit(arg=[]) if arg != [] @limit = arg else @limit end end
some_msg(arg=nil)
click to toggle source
# File lib/megam/core/eventsstorage.rb, line 62 def some_msg(arg=nil) if arg != nil @some_msg = arg else @some_msg end end
to_hash()
click to toggle source
Transform the ruby obj -> to a Hash
# File lib/megam/core/eventsstorage.rb, line 72 def to_hash index_hash = Hash.new index_hash["json_claz"] = self.class.name index_hash["account_id"] = account_id index_hash["event_type"] = event_type index_hash["data"] = data index_hash["limit"] = limit index_hash["created_at"] = created_at index_hash["some_msg"] = some_msg index_hash end
to_json(*a)
click to toggle source
Serialize this object as a hash: called from JsonCompat. Verify if this called from JsonCompat during testing.
# File lib/megam/core/eventsstorage.rb, line 86 def to_json(*a) for_json.to_json(*a) end
to_s()
click to toggle source
# File lib/megam/core/eventsstorage.rb, line 151 def to_s Megam::Stuff.styled_hash(to_hash) end