Class: Megam::Domains
Instance Attribute Summary
Attributes inherited from ServerAPI
#api_key, #email, #host, #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
24
|
# File 'lib/megam/core/domains.rb', line 18
def initialize(o)
@id = nil
@org_id = nil
@name = nil
@created_at = nil
super(o)
end
|
Class Method Details
.create(o) ⇒ Object
112
113
114
115
|
# File 'lib/megam/core/domains.rb', line 112
def self.create(o)
dom = from_hash(o)
dom.create
end
|
.from_hash(o) ⇒ Object
97
98
99
100
101
|
# File 'lib/megam/core/domains.rb', line 97
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)
88
89
90
91
92
93
94
95
|
# File 'lib/megam/core/domains.rb', line 88
def self.json_create(o)
dmn = new({})
dmn.id(o["id"]) if o.has_key?("id")
dmn.org_id(o["org_id"]) if o.has_key?("org_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
117
118
119
120
|
# File 'lib/megam/core/domains.rb', line 117
def self.list(o)
dom = from_hash(o)
dom.megam_rest.get_domains
end
|
Instance Method Details
#create ⇒ Object
122
123
124
|
# File 'lib/megam/core/domains.rb', line 122
def create
megam_rest.post_domains(to_hash)
end
|
#created_at(arg = nil) ⇒ Object
55
56
57
58
59
60
61
|
# File 'lib/megam/core/domains.rb', line 55
def created_at(arg=nil)
if arg != nil
@created_at = arg
else
@created_at
end
end
|
#domain ⇒ Object
26
27
28
|
# File 'lib/megam/core/domains.rb', line 26
def domain
self
end
|
#for_json ⇒ Object
77
78
79
80
81
82
83
84
85
|
# File 'lib/megam/core/domains.rb', line 77
def for_json
result = {
"id" => id,
"org_id" => org_id,
"name" => name,
"created_at" => created_at
}
result
end
|
#from_hash(o) ⇒ Object
104
105
106
107
108
109
110
|
# File 'lib/megam/core/domains.rb', line 104
def from_hash(o)
@id = o[:id] if o.has_key?(:id)
@org_id = o[:org_id] if o.has_key?(:org_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
30
31
32
33
34
35
36
|
# File 'lib/megam/core/domains.rb', line 30
def id(arg=nil)
if arg != nil
@id = arg
else
@id
end
end
|
#name(arg = nil) ⇒ Object
47
48
49
50
51
52
53
|
# File 'lib/megam/core/domains.rb', line 47
def name(arg=nil)
if arg != nil
@name = arg
else
@name
end
end
|
#org_id(arg = nil) ⇒ Object
38
39
40
41
42
43
44
|
# File 'lib/megam/core/domains.rb', line 38
def org_id(arg=nil)
if arg != nil
@org_id = arg
else
@org_id
end
end
|
#show ⇒ Object
126
127
128
|
# File 'lib/megam/core/domains.rb', line 126
def show
megam_rest.get_domains(to_hash)
end
|
#to_hash ⇒ Object
63
64
65
66
67
68
69
70
71
|
# File 'lib/megam/core/domains.rb', line 63
def to_hash
index_hash = Hash.new
index_hash["json_claz"] = self.class.name
index_hash["id"] = id
index_hash["org_id"] = org_id
index_hash["name"] = name
index_hash["created_at"] = created_at
index_hash
end
|
#to_json(*a) ⇒ Object
73
74
75
|
# File 'lib/megam/core/domains.rb', line 73
def to_json(*a)
for_json.to_json(*a)
end
|