Class: Megam::License
Instance Attribute Summary
Attributes inherited from RestAdapter
#api_key, #email, #headers, #host, #master_key, #org_id, #password_hash
Class Method Summary
collapse
Instance Method Summary
collapse
Methods inherited from RestAdapter
#megam_rest
Constructor Details
#initialize(o) ⇒ License
Returns a new instance of License.
3
4
5
6
7
|
# File 'lib/megam/core/license.rb', line 3
def initialize(o)
@data = nil
@some_msg = {}
super(o)
end
|
Class Method Details
.create(params) ⇒ Object
78
79
80
81
|
# File 'lib/megam/core/license.rb', line 78
def self.create(params)
acct = from_hash(params)
acct.create
end
|
.from_hash(o) ⇒ Object
67
68
69
70
71
|
# 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) ⇒ Object
56
57
58
59
60
61
62
63
64
65
|
# File 'lib/megam/core/license.rb', line 56
def self.json_create(o)
license = new({})
license.data(o["results"]["data"]) if o["results"]
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
|
.show(params) ⇒ Object
Show a particular License by id, Megam::License
90
91
92
93
|
# File 'lib/megam/core/license.rb', line 90
def self.show(params)
pre = self.new(params)
pre.megam_rest.get_license(params["id"])
end
|
Instance Method Details
#create ⇒ Object
Create the predef via the REST API
84
85
86
|
# File 'lib/megam/core/license.rb', line 84
def create
megam_rest.post_license(to_hash)
end
|
#data(arg = nil) ⇒ Object
14
15
16
17
18
19
20
|
# File 'lib/megam/core/license.rb', line 14
def data(arg=nil)
if arg != nil
@data = arg
else
@data
end
end
|
#error? ⇒ Boolean
30
31
32
|
# 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 ⇒ Object
48
49
50
51
52
53
|
# File 'lib/megam/core/license.rb', line 48
def for_json
result = {
"data" => data
}
result
end
|
#from_hash(o) ⇒ Object
73
74
75
76
|
# File 'lib/megam/core/license.rb', line 73
def from_hash(o)
@data = o[:data] if o.has_key?(:data)
self
end
|
#license ⇒ Object
9
10
11
|
# File 'lib/megam/core/license.rb', line 9
def license
self
end
|
#some_msg(arg = nil) ⇒ Object
22
23
24
25
26
27
28
|
# 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 ⇒ Object
Transform the ruby obj -> to a Hash
35
36
37
38
39
40
|
# 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) ⇒ Object
Serialize this object as a hash: called from JsonCompat. Verify if this called from JsonCompat during testing.
44
45
46
|
# File 'lib/megam/core/license.rb', line 44
def to_json(*a)
for_json.to_json(*a)
end
|