Class: Megam::Domains
Instance Attribute Summary
Attributes inherited from ServerAPI
#api_key, #email, #host, #org_id, #password
Class Method Summary
collapse
Instance Method Summary
collapse
Methods inherited from ServerAPI
#megam_rest
Constructor Details
#initialize(o) ⇒ Domains
Returns a new instance of Domains.
18
19
20
21
22
23
|
# File 'lib/megam/core/domains.rb', line 18
def initialize(o)
@id = nil
@name = nil
@created_at = nil
super(o)
end
|
Class Method Details
.create(o) ⇒ Object
98
99
100
101
|
# File 'lib/megam/core/domains.rb', line 98
def self.create(o)
dom = from_hash(o)
dom.create
end
|
.from_hash(o) ⇒ Object
84
85
86
87
88
|
# File 'lib/megam/core/domains.rb', line 84
def self.from_hash(o)
org = self.new(o)
org.from_hash(o)
org
end
|
.json_create(o) ⇒ Object
Create a Megam::Domains from JSON (used by the backgroud job workers)
76
77
78
79
80
81
82
|
# File 'lib/megam/core/domains.rb', line 76
def self.json_create(o)
dmn = new
dmn.id(o["id"]) if o.has_key?("id")
dmn.name(o["name"]) if o.has_key?("name")
dmn.created_at(o["created_at"]) if o.has_key?("created_at")
dmn
end
|
.list(o) ⇒ Object
103
104
105
106
|
# File 'lib/megam/core/domains.rb', line 103
def self.list(o)
dom = from_hash(o)
dom.megam_rest.get_domains
end
|
Instance Method Details
#create ⇒ Object
108
109
110
|
# File 'lib/megam/core/domains.rb', line 108
def create
megam_rest.post_domains(to_hash)
end
|
#created_at(arg = nil) ⇒ Object
45
46
47
48
49
50
51
|
# File 'lib/megam/core/domains.rb', line 45
def created_at(arg=nil)
if arg != nil
@created_at = arg
else
@created_at
end
end
|
#domain ⇒ Object
25
26
27
|
# File 'lib/megam/core/domains.rb', line 25
def domain
self
end
|
#for_json ⇒ Object
66
67
68
69
70
71
72
73
|
# File 'lib/megam/core/domains.rb', line 66
def for_json
result = {
"id" => id,
"name" => name,
"created_at" => created_at
}
result
end
|
#from_hash(o) ⇒ Object
91
92
93
94
95
96
|
# File 'lib/megam/core/domains.rb', line 91
def from_hash(o)
@id = o[:id] if o.has_key?(:id)
@name = o[:name] if o.has_key?(:name)
@created_at = o[:created_at] if o.has_key?(:created_at)
self
end
|
#id(arg = nil) ⇒ Object
29
30
31
32
33
34
35
|
# File 'lib/megam/core/domains.rb', line 29
def id(arg=nil)
if arg != nil
@id = arg
else
@id
end
end
|
#name(arg = nil) ⇒ Object
37
38
39
40
41
42
43
|
# File 'lib/megam/core/domains.rb', line 37
def name(arg=nil)
if arg != nil
@name = arg
else
@name
end
end
|
#show ⇒ Object
112
113
114
|
# File 'lib/megam/core/domains.rb', line 112
def show
megam_rest.get_domains(to_hash)
end
|
#to_hash ⇒ Object
53
54
55
56
57
58
59
60
|
# File 'lib/megam/core/domains.rb', line 53
def to_hash
index_hash = Hash.new
index_hash["json_claz"] = self.class.name
index_hash["id"] = id
index_hash["name"] = name
index_hash["created_at"] = created_at
index_hash
end
|
#to_json(*a) ⇒ Object
62
63
64
|
# File 'lib/megam/core/domains.rb', line 62
def to_json(*a)
for_json.to_json(*a)
end
|