class Megam::Addons
Public Class Methods
create(params)
click to toggle source
# File lib/megam/core/addons.rb, line 142 def self.create(params) acct = from_hash(params) acct.create end
from_hash(o)
click to toggle source
# File lib/megam/core/addons.rb, line 126 def self.from_hash(o) adn = self.new(o) adn.from_hash(o) adn end
json_create(o)
click to toggle source
# File lib/megam/core/addons.rb, line 110 def self.json_create(o) adn = new({}) adn.id(o["id"]) if o.has_key?("id") adn.provider_id(o["provider_id"]) if o.has_key?("provider_id") adn.account_id(o["account_id"]) if o.has_key?("account_id") adn.provider_name(o["provider_name"]) if o.has_key?("provider_name") adn.options(o["options"]) if o.has_key?("options") adn.created_at(o["created_at"]) if o.has_key?("created_at") #success or error adn.some_msg[:code] = o["code"] if o.has_key?("code") adn.some_msg[:msg_type] = o["msg_type"] if o.has_key?("msg_type") adn.some_msg[:msg]= o["msg"] if o.has_key?("msg") adn.some_msg[:links] = o["links"] if o.has_key?("links") adn end
new(o)
click to toggle source
Calls superclass method
Megam::RestAdapter::new
# File lib/megam/core/addons.rb, line 3 def initialize(o) @id = nil @provider_id = nil @account_id = nil @provider_name = nil @options = [] @created_at = nil @some_msg = {} super(o) end
show(params)
click to toggle source
Show a particular addon by provider_name
, Megam::Addon
# File lib/megam/core/addons.rb, line 158 def self.show(params) pre = self.new(params) pre.megam_rest.get_addon(params["provider"]) end
Public Instance Methods
account_id(arg=nil)
click to toggle source
# File lib/megam/core/addons.rb, line 34 def account_id(arg=nil) if arg != nil @account_id= arg else @account_id end end
addons()
click to toggle source
# File lib/megam/core/addons.rb, line 14 def addons self end
create()
click to toggle source
Create the addons via the REST API
# File lib/megam/core/addons.rb, line 148 def create megam_rest.post_addons(to_hash) end
created_at(arg=nil)
click to toggle source
# File lib/megam/core/addons.rb, line 58 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/addons.rb, line 74 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/addons.rb, line 97 def for_json result = { "id" => id, "provider_id" => provider_id, "account_id" => account_id, "provider_name" => provider_name , "options" => options, "created_at" => created_at } result end
from_hash(o)
click to toggle source
# File lib/megam/core/addons.rb, line 132 def from_hash(o) @id = o[:id] if o.has_key?(:id) @provider_id = o[:provider_id] if o.has_key?(:provider_id) @account_id = o[:account_id] if o.has_key?(:account_id) @provider_name = o[:provider_name] if o.has_key?(:provider_name) @options = o[:options] if o.has_key?(:options) @created_at = o[:created_at] if o.has_key?(:created_at) self end
id(arg=nil)
click to toggle source
# File lib/megam/core/addons.rb, line 18 def id(arg=nil) if arg != nil @id = arg else @id end end
options(arg=[])
click to toggle source
# File lib/megam/core/addons.rb, line 50 def options(arg=[]) if arg != [] @options = arg else @options end end
provider_id(arg=nil)
click to toggle source
# File lib/megam/core/addons.rb, line 26 def provider_id(arg=nil) if arg != nil @provider_id= arg else @provider_id end end
provider_name(arg=nil)
click to toggle source
# File lib/megam/core/addons.rb, line 42 def provider_name(arg=nil) if arg != nil @provider_name = arg else @provider_name end end
some_msg(arg=nil)
click to toggle source
# File lib/megam/core/addons.rb, line 66 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/addons.rb, line 79 def to_hash index_hash = Hash.new index_hash["json_claz"] = self.class.name index_hash["id"] = id index_hash["provider_id"] = provider_id index_hash["account_id"] = account_id index_hash["provider_name"] = provider_name index_hash["options"] = options 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/addons.rb, line 93 def to_json(*a) for_json.to_json(*a) end
to_s()
click to toggle source
# File lib/megam/core/addons.rb, line 164 def to_s Megam::Stuff.styled_hash(to_hash) end