Class: Megam::MarketPlaceAddons
- Defined in:
- lib/megam/core/marketplace_addon.rb
Instance Attribute Summary
Attributes inherited from ServerAPI
Class Method Summary collapse
- .create(o, tmp_email = nil, tmp_api_key = nil, tmp_host = nil) ⇒ Object
- .from_hash(o, tmp_email = nil, tmp_api_key = nil, tmp_host = nil) ⇒ Object
- .json_create(o) ⇒ Object
-
.list(node_name, tmp_email = nil, tmp_api_key = nil, tmp_host = nil) ⇒ Object
Load a account by email_p.
Instance Method Summary collapse
- #config(arg = nil) ⇒ Object
- #config_id(arg = nil) ⇒ Object
-
#create ⇒ Object
Create the addon 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, host = nil) ⇒ MarketPlaceAddons
constructor
A new instance of MarketPlaceAddons.
- #market_place_addons ⇒ Object
- #marketplace_id(arg = nil) ⇒ Object
- #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, host = nil) ⇒ MarketPlaceAddons
Returns a new instance of MarketPlaceAddons.
19 20 21 22 23 24 25 26 27 28 29 |
# File 'lib/megam/core/marketplace_addon.rb', line 19 def initialize(email=nil, api_key=nil, host=nil) @id = nil @node_id = nil @node_name = nil @marketplace_id = nil @config = nil @config_id = nil @created_at = nil @some_msg = {} super(email,api_key,host) end |
Class Method Details
.create(o, tmp_email = nil, tmp_api_key = nil, tmp_host = nil) ⇒ Object
173 174 175 176 |
# File 'lib/megam/core/marketplace_addon.rb', line 173 def self.create(o,tmp_email=nil, tmp_api_key=nil, tmp_host=nil) acct = from_hash(o,tmp_email, tmp_api_key, tmp_host) acct.create end |
.from_hash(o, tmp_email = nil, tmp_api_key = nil, tmp_host = nil) ⇒ Object
156 157 158 159 160 |
# File 'lib/megam/core/marketplace_addon.rb', line 156 def self.from_hash(o,tmp_email=nil, tmp_api_key=nil, tmp_host=nil) addon = self.new(tmp_email, tmp_api_key, tmp_host) addon.from_hash(o) addon end |
.json_create(o) ⇒ Object
138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 |
# File 'lib/megam/core/marketplace_addon.rb', line 138 def self.json_create(o) addon = new addon.id(o["id"]) if o.has_key?("id") addon.node_id(o["node_id"]) if o.has_key?("node_id") addon.node_name(o["node_name"]) if o.has_key?("node_name") addon.marketplace_id(o["marketplace_id"]) if o.has_key?("marketplace_id") addon.config(o["config"]) if o.has_key?("config") addon.config_id(o["config_id"]) if o.has_key?("config_id") addon.created_at(o["created_at"]) if o.has_key?("created_at") addon.some_msg[:code] = o["code"] if o.has_key?("code") addon.some_msg[:msg_type] = o["msg_type"] if o.has_key?("msg_type") addon.some_msg[:msg]= o["msg"] if o.has_key?("msg") addon.some_msg[:links] = o["links"] if o.has_key?("links") addon end |
.list(node_name, tmp_email = nil, tmp_api_key = nil, tmp_host = nil) ⇒ Object
Load a account by email_p
184 185 186 187 188 |
# File 'lib/megam/core/marketplace_addon.rb', line 184 def self.list(node_name,tmp_email=nil, tmp_api_key=nil, tmp_host=nil) addon = self.new(tmp_email, tmp_api_key, tmp_host) addon.megam_rest.get_addons(node_name) #self end |
Instance Method Details
#config(arg = nil) ⇒ Object
76 77 78 79 80 81 82 |
# File 'lib/megam/core/marketplace_addon.rb', line 76 def config(arg=nil) if arg != nil @config = arg else @config end end |
#config_id(arg = nil) ⇒ Object
68 69 70 71 72 73 74 |
# File 'lib/megam/core/marketplace_addon.rb', line 68 def config_id(arg=nil) if arg != nil @config_id = arg else @config_id end end |
#create ⇒ Object
Create the addon via the REST API
179 180 181 |
# File 'lib/megam/core/marketplace_addon.rb', line 179 def create megam_rest.post_addon(to_hash) end |
#created_at(arg = nil) ⇒ Object
84 85 86 87 88 89 90 |
# File 'lib/megam/core/marketplace_addon.rb', line 84 def created_at(arg=nil) if arg != nil @created_at = arg else @created_at end end |
#error? ⇒ Boolean
99 100 101 |
# File 'lib/megam/core/marketplace_addon.rb', line 99 def error? crocked = true if (some_msg.has_key?(:msg_type) && some_msg[:msg_type] == "error") end |
#for_json ⇒ Object
124 125 126 127 128 129 130 131 132 133 134 135 |
# File 'lib/megam/core/marketplace_addon.rb', line 124 def for_json result = { "id" => id, "node_id" => node_id, "node_name" => node_name, "marketplace_id" => marketplace_id, "config" => {}, "config_id" => config_id, "created_at" => created_at } result end |
#from_hash(o) ⇒ Object
162 163 164 165 166 167 168 169 170 171 |
# File 'lib/megam/core/marketplace_addon.rb', line 162 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") @marketplace_id = o["marketplace_id"] if o.has_key?("marketplace_id") @config = o["config"] if o.has_key?("config") @config_id = o["config_id"] if o.has_key?("config_id") @created_at = o["created_at"] if o.has_key?("created_at") self end |
#id(arg = nil) ⇒ Object
36 37 38 39 40 41 42 |
# File 'lib/megam/core/marketplace_addon.rb', line 36 def id(arg=nil) if arg != nil @id = arg else @id end end |
#market_place_addons ⇒ Object
31 32 33 |
# File 'lib/megam/core/marketplace_addon.rb', line 31 def market_place_addons self end |
#marketplace_id(arg = nil) ⇒ Object
60 61 62 63 64 65 66 |
# File 'lib/megam/core/marketplace_addon.rb', line 60 def marketplace_id(arg=nil) if arg != nil @marketplace_id = arg else @marketplace_id end end |
#node_id(arg = nil) ⇒ Object
44 45 46 47 48 49 50 |
# File 'lib/megam/core/marketplace_addon.rb', line 44 def node_id(arg=nil) if arg != nil @node_id = arg else @node_id end end |
#node_name(arg = nil) ⇒ Object
52 53 54 55 56 57 58 |
# File 'lib/megam/core/marketplace_addon.rb', line 52 def node_name(arg=nil) if arg != nil @node_name = arg else @node_name end end |
#some_msg(arg = nil) ⇒ Object
91 92 93 94 95 96 97 |
# File 'lib/megam/core/marketplace_addon.rb', line 91 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
104 105 106 107 108 109 110 111 112 113 114 115 116 |
# File 'lib/megam/core/marketplace_addon.rb', line 104 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["marketplace_id"] = marketplace_id index_hash["config"] = config index_hash["config_id"] = config_id 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.
120 121 122 |
# File 'lib/megam/core/marketplace_addon.rb', line 120 def to_json(*a) for_json.to_json(*a) end |
#to_s ⇒ Object
190 191 192 |
# File 'lib/megam/core/marketplace_addon.rb', line 190 def to_s Megam::Stuff.styled_hash(to_hash) end |