class Megam::Request
Public Class Methods
create(params)
click to toggle source
# File lib/megam/core/request.rb, line 171 def self.create(params) acct = from_hash(params) acct.create end
from_hash(o)
click to toggle source
# File lib/megam/core/request.rb, line 152 def self.from_hash(o) node = self.new(o) node.from_hash(o) node end
json_create(o)
click to toggle source
# File lib/megam/core/request.rb, line 134 def self.json_create(o) node = new(o) node.id(o["id"]) if o.has_key?("id") node.account_id(o["account_id"]) if o.has_key?("account_id") node.cat_id(o["cat_id"]) if o.has_key?("cat_id") node.name(o["name"]) if o.has_key?("name") node.cattype(o["cattype"]) if o.has_key?("cattype") node.action(o["action"]) if o.has_key?("action") node.category(o["category"]) if o.has_key?("category") node.created_at(o["created_at"]) if o.has_key?("created_at") #success or error node.some_msg[:code] = o["code"] if o.has_key?("code") node.some_msg[:msg_type] = o["msg_type"] if o.has_key?("msg_type") node.some_msg[:msg]= o["msg"] if o.has_key?("msg") node.some_msg[:links] = o["links"] if o.has_key?("links") node end
list(params)
click to toggle source
have to check list
# File lib/megam/core/request.rb, line 187 def self.list(params) prede = self.new(params) prede.megam_rest.get_request(n_name) end
new(params)
click to toggle source
Calls superclass method
Megam::RestAdapter::new
# File lib/megam/core/request.rb, line 3 def initialize(params) @id = nil @account_id = nil @cat_id = nil @name = nil @cattype = nil @action = nil @category = nil @some_msg = {} @created_at = nil super(params) end
show(params)
click to toggle source
# File lib/megam/core/request.rb, line 182 def self.show(params) prede = self.new(params) prede.megam_rest.get_requests end
Public Instance Methods
account_id(arg=nil)
click to toggle source
# File lib/megam/core/request.rb, line 29 def account_id(arg=nil) if arg != nil @account_id = arg else @account_id end end
action(arg=nil)
click to toggle source
# File lib/megam/core/request.rb, line 60 def action(arg=nil) if arg != nil @action = arg else @action end end
cat_id(arg=nil)
click to toggle source
# File lib/megam/core/request.rb, line 37 def cat_id(arg=nil) if arg != nil @cat_id = arg else @cat_id end end
category(arg=nil)
click to toggle source
# File lib/megam/core/request.rb, line 69 def category(arg=nil) if arg != nil @category = arg else @category end end
cattype(arg=nil)
click to toggle source
# File lib/megam/core/request.rb, line 52 def cattype(arg=nil) if arg != nil @cattype = arg else @cattype end end
create()
click to toggle source
Create the node via the REST API
# File lib/megam/core/request.rb, line 177 def create megam_rest.post_request(to_hash) end
created_at(arg=nil)
click to toggle source
# File lib/megam/core/request.rb, line 78 def created_at(arg=nil) if arg != nil @created_at = arg else @created_at end end
error?()
click to toggle source
# File lib/megam/core/request.rb, line 94 def error? crocked = true if (some_msg.has_key?(:msg_type) && some_msg[:msg_type] == "error") end
for_json()
click to toggle source
# File lib/megam/core/request.rb, line 119 def for_json result = { "id" => id, "account_id" => account_id, "cat_id" => cat_id, "name" => name, "cattype" => cattype, "action" => action, "category" => category, "created_at" => created_at } result end
from_hash(o)
click to toggle source
# File lib/megam/core/request.rb, line 158 def from_hash(o) @id = o[:id] if o.has_key?(:id) @account_id = o[:account_id] if o.has_key?(:account_id) @cat_id = o[:cat_id] if o.has_key?(:cat_id) @name = o[:name] if o.has_key?(:name) @cattype = o[:cattype] if o.has_key?(:cattype) @action = o[:action] if o.has_key?(:action) @category = o[:category] if o.has_key?(:category) @created_at = o[:created_at] if o.has_key?(:created_at) self end
id(arg=nil)
click to toggle source
# File lib/megam/core/request.rb, line 21 def id(arg=nil) if arg != nil @id = arg else @id end end
name(arg=nil)
click to toggle source
# File lib/megam/core/request.rb, line 45 def name(arg=nil) if arg != nil @name = arg else @name end end
request()
click to toggle source
# File lib/megam/core/request.rb, line 16 def request self end
some_msg(arg=nil)
click to toggle source
# File lib/megam/core/request.rb, line 86 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/request.rb, line 99 def to_hash index_hash = Hash.new index_hash["json_claz"] = self.class.name index_hash["id"] = id index_hash["account_id"] = account_id index_hash["cat_id"] = cat_id index_hash["name"] = name index_hash["cattype"] = cattype index_hash["action"] = action index_hash["category"] = category index_hash["created_at"] = created_at 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/request.rb, line 115 def to_json(*a) for_json.to_json(*a) end
to_s()
click to toggle source
# File lib/megam/core/request.rb, line 192 def to_s Megam::Stuff.styled_hash(to_hash) end