Class: Megam::Appdefns
- Defined in:
- lib/megam/core/appdefns.rb
Instance Attribute Summary
Attributes inherited from ServerAPI
Class Method Summary collapse
- .create(o, tmp_email = nil, tmp_api_key = nil) ⇒ Object
- .from_hash(o, tmp_email = nil, tmp_api_key = nil) ⇒ Object
- .json_create(o) ⇒ Object
-
.show(id, tmp_email = nil, tmp_api_key = nil) ⇒ Object
Load a account by email_p.
-
.show_by_node(node_name, id, tmp_email = nil, tmp_api_key = nil) ⇒ Object
Load a account by email_p.
Instance Method Summary collapse
- #appdefns(arg = nil) ⇒ Object
-
#create ⇒ Object
Create the node via the REST API.
- #created_at(arg = nil) ⇒ Object
- #error? ⇒ Boolean
- #for_json ⇒ Object
- #from_hash(o) ⇒ Object
- #id(arg = nil) ⇒ Object
-
#initialize(email = nil, api_key = nil) ⇒ Appdefns
constructor
A new instance of Appdefns.
- #node_id(arg = nil) ⇒ Object
- #node_name(arg = nil) ⇒ Object
- #some_msg(arg = nil) ⇒ Object
-
#to_hash ⇒ Object
Transform the ruby obj -> to a Hash.
-
#to_json(*a) ⇒ Object
Serialize this object as a hash: called from JsonCompat.
- #to_s ⇒ Object
Methods inherited from ServerAPI
Constructor Details
#initialize(email = nil, api_key = nil) ⇒ Appdefns
Returns a new instance of Appdefns.
19 20 21 22 23 24 25 26 27 |
# File 'lib/megam/core/appdefns.rb', line 19 def initialize(email=nil, api_key=nil) @id = nil @node_id = nil @node_name = nil @appdefns ={} @created_at = nil @some_msg = {} super(email, api_key) end |
Class Method Details
.create(o, tmp_email = nil, tmp_api_key = nil) ⇒ Object
154 155 156 157 |
# File 'lib/megam/core/appdefns.rb', line 154 def self.create(o,tmp_email=nil, tmp_api_key=nil) acct = from_hash(o,tmp_email, tmp_api_key) acct.create end |
.from_hash(o, tmp_email = nil, tmp_api_key = nil) ⇒ Object
139 140 141 142 143 |
# File 'lib/megam/core/appdefns.rb', line 139 def self.from_hash(o,tmp_email=nil, tmp_api_key=nil) appdefns = self.new(tmp_email, tmp_api_key) appdefns.from_hash(o) appdefns end |
.json_create(o) ⇒ Object
117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 |
# File 'lib/megam/core/appdefns.rb', line 117 def self.json_create(o) appdefns = new appdefns.id(o["id"]) if o.has_key?("id") appdefns.node_id(o["node_id"]) if o.has_key?("node_id") appdefns.node_name(o["node_name"]) if o.has_key?("node_name") appdefns.created_at(o["created_at"]) if o.has_key?("created_at") #APP DEFINITIONS op = o["appdefns"] appdefns.appdefns[:timetokill] = op["timetokill"] if op && op.has_key?("timetokill") appdefns.appdefns[:metered] = op["metered"] if op && op.has_key?("metered") appdefns.appdefns[:logging]= op["logging"] if op && op.has_key?("logging") appdefns.appdefns[:runtime_exec] = op["runtime_exec"] if op && op.has_key?("runtime_exec") appdefns.some_msg[:code] = o["code"] if o.has_key?("code") appdefns.some_msg[:msg_type] = o["msg_type"] if o.has_key?("msg_type") appdefns.some_msg[:msg]= o["msg"] if o.has_key?("msg") appdefns.some_msg[:links] = o["links"] if o.has_key?("links") appdefns end |
.show(id, tmp_email = nil, tmp_api_key = nil) ⇒ Object
Load a account by email_p
165 166 167 168 |
# File 'lib/megam/core/appdefns.rb', line 165 def self.show(id,tmp_email=nil, tmp_api_key=nil) appdefns = self.new(tmp_email, tmp_api_key) appdefns.megam_rest.get_appdefn(id) end |
.show_by_node(node_name, id, tmp_email = nil, tmp_api_key = nil) ⇒ Object
Load a account by email_p
171 172 173 174 |
# File 'lib/megam/core/appdefns.rb', line 171 def self.show_by_node(node_name, id,tmp_email=nil, tmp_api_key=nil) appdefns = self.new(tmp_email, tmp_api_key) appdefns.megam_rest.get_appdefn(node_name,id) end |
Instance Method Details
#appdefns(arg = nil) ⇒ Object
29 30 31 |
# File 'lib/megam/core/appdefns.rb', line 29 def appdefns self end |
#create ⇒ Object
Create the node via the REST API
160 161 162 |
# File 'lib/megam/core/appdefns.rb', line 160 def create megam_rest.post_appdefn(to_hash) end |
#created_at(arg = nil) ⇒ Object
66 67 68 69 70 71 72 |
# File 'lib/megam/core/appdefns.rb', line 66 def created_at(arg=nil) if arg != nil @created_at = arg else @created_at end end |
#error? ⇒ Boolean
82 83 84 |
# File 'lib/megam/core/appdefns.rb', line 82 def error? crocked = true if (some_msg.has_key?(:msg_type) && some_msg[:msg_type] == "error") end |
#for_json ⇒ Object
105 106 107 108 109 110 111 112 113 114 |
# File 'lib/megam/core/appdefns.rb', line 105 def for_json result = { "id" => id, "node_id" => node_id, "node_name" => node_name, "appdefns" => appdefns, "created_at" => created_at } result end |
#from_hash(o) ⇒ Object
145 146 147 148 149 150 151 152 |
# File 'lib/megam/core/appdefns.rb', line 145 def from_hash(o) @id = o["id"] if o.has_key?("id") @node_id = o["node_id"] if o.has_key?("node_id") @node_name = o["node_name"] if o.has_key?("node_name") @appdefns = o["appdefns"] if o.has_key?("appdefns") @created_at = o["created_at"] if o.has_key?("created_at") self end |
#id(arg = nil) ⇒ Object
34 35 36 37 38 39 40 |
# File 'lib/megam/core/appdefns.rb', line 34 def id(arg=nil) if arg != nil @id = arg else @id end end |
#node_id(arg = nil) ⇒ Object
42 43 44 45 46 47 48 |
# File 'lib/megam/core/appdefns.rb', line 42 def node_id(arg=nil) if arg != nil @node_id = arg else @node_id end end |
#node_name(arg = nil) ⇒ Object
50 51 52 53 54 55 56 |
# File 'lib/megam/core/appdefns.rb', line 50 def node_name(arg=nil) if arg != nil @node_name = arg else @node_name end end |
#some_msg(arg = nil) ⇒ Object
74 75 76 77 78 79 80 |
# File 'lib/megam/core/appdefns.rb', line 74 def some_msg(arg=nil) if arg != nil @some_msg = arg else @some_msg end end |
#to_hash ⇒ Object
Transform the ruby obj -> to a Hash
87 88 89 90 91 92 93 94 95 96 97 |
# File 'lib/megam/core/appdefns.rb', line 87 def to_hash index_hash = Hash.new index_hash["json_claz"] = self.class.name index_hash["id"] = id index_hash["node_id"] = node_id index_hash["node_name"] = node_name index_hash["appdefns"] = appdefns index_hash["created_at"] = created_at index_hash["some_msg"] = some_msg index_hash end |
#to_json(*a) ⇒ Object
Serialize this object as a hash: called from JsonCompat. Verify if this called from JsonCompat during testing.
101 102 103 |
# File 'lib/megam/core/appdefns.rb', line 101 def to_json(*a) for_json.to_json(*a) end |
#to_s ⇒ Object
176 177 178 |
# File 'lib/megam/core/appdefns.rb', line 176 def to_s Megam::Stuff.styled_hash(to_hash) end |