class Megam::License

Public Class Methods

create(params) click to toggle source
# File lib/megam/core/license.rb, line 78
def self.create(params)
    acct = from_hash(params)
    acct.create
end
from_hash(o) click to toggle source
# File lib/megam/core/license.rb, line 67
def self.from_hash(o)
    license = self.new(o)
    license.from_hash(o)
    license
end
json_create(o) click to toggle source
# File lib/megam/core/license.rb, line 56
def self.json_create(o)
    license = new({})
     license.data(o["results"]["data"]) if o["results"]
    #success or error
    license.some_msg[:code] = o["code"] if o.has_key?("code")
    license.some_msg[:msg_type] = o["msg_type"] if o.has_key?("msg_type")
    license.some_msg[:msg]= o["msg"] if o.has_key?("msg")
    license.some_msg[:links] = o["links"] if o.has_key?("links")
    license
end
new(o) click to toggle source
Calls superclass method Megam::RestAdapter::new
# File lib/megam/core/license.rb, line 3
def initialize(o)
    @data = nil
    @some_msg = {}
    super(o)
end
show(params) click to toggle source

Show a particular License by id, Megam::License

# File lib/megam/core/license.rb, line 90
def self.show(params)
    pre = self.new(params)
    pre.megam_rest.get_license(params["id"])
end

Public Instance Methods

create() click to toggle source

Create the predef via the REST API

# File lib/megam/core/license.rb, line 84
def create
    megam_rest.post_license(to_hash)
end
data(arg=nil) click to toggle source
# File lib/megam/core/license.rb, line 14
def data(arg=nil)
    if arg != nil
        @data = arg
    else
        @data
    end
end
error?() click to toggle source
# File lib/megam/core/license.rb, line 30
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/license.rb, line 48
def for_json
    result = {
        "data" => data
    }
    result
end
from_hash(o) click to toggle source
# File lib/megam/core/license.rb, line 73
def from_hash(o)
    @data   = o[:data] if o.has_key?(:data)
    self
end
license() click to toggle source
# File lib/megam/core/license.rb, line 9
def license
    self
end
some_msg(arg=nil) click to toggle source
# File lib/megam/core/license.rb, line 22
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/license.rb, line 35
def to_hash
    index_hash = Hash.new
    index_hash["json_claz"] = self.class.name
    index_hash["data"] = data
    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/license.rb, line 44
def to_json(*a)
    for_json.to_json(*a)
end
to_s() click to toggle source
# File lib/megam/core/license.rb, line 95
def to_s
    Megam::Stuff.styled_hash(to_hash)
    #"---> Megam::Account:[error=#{error?}]\n"+
end