Class: Megam::Domains
Instance Attribute Summary
Attributes inherited from ServerAPI
Class Method Summary collapse
- .create(o) ⇒ Object
- .from_hash(o) ⇒ Object
-
.json_create(o) ⇒ Object
Create a Megam::Domains from JSON (used by the backgroud job workers).
-
.show(email, api_key = nil) ⇒ Object
Load a Domain by email_p.
Instance Method Summary collapse
- #create ⇒ Object
- #created_at(arg = nil) ⇒ Object
- #domain ⇒ Object
- #for_json ⇒ Object
- #from_hash(o) ⇒ Object
- #id(arg = nil) ⇒ Object
-
#initialize(email = nil, api_key = nil) ⇒ Domains
constructor
A new instance of Domains.
- #name(arg = nil) ⇒ Object
-
#to_hash ⇒ Object
Transform the ruby obj -> to a Hash.
- #to_json(*a) ⇒ Object
- #to_s ⇒ Object
Methods inherited from ServerAPI
Constructor Details
#initialize(email = nil, api_key = nil) ⇒ Domains
Returns a new instance of Domains.
19 20 21 22 23 24 |
# File 'lib/megam/core/domains.rb', line 19 def initialize(email=nil, api_key=nil) @id = nil @name = nil @created_at = nil super(email, api_key) end |
Class Method Details
.create(o) ⇒ Object
106 107 108 109 |
# File 'lib/megam/core/domains.rb', line 106 def self.create(o) dmn = from_hash(o) dmn.create end |
.from_hash(o) ⇒ Object
93 94 95 96 97 |
# File 'lib/megam/core/domains.rb', line 93 def self.from_hash(o) dmn = self.new(o[:email], o[:api_key]) dmn.from_hash(o) dmn end |
.json_create(o) ⇒ Object
Create a Megam::Domains from JSON (used by the backgroud job workers)
85 86 87 88 89 90 91 |
# File 'lib/megam/core/domains.rb', line 85 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 |
.show(email, api_key = nil) ⇒ Object
Load a Domain by email_p
112 113 114 115 |
# File 'lib/megam/core/domains.rb', line 112 def self.show(email,api_key=nil) dmn = self.new(email, api_key) dmn.megam_rest.get_domains(email) end |
Instance Method Details
#create ⇒ Object
118 119 120 |
# File 'lib/megam/core/domains.rb', line 118 def create megam_rest.post_domains(to_hash) end |
#created_at(arg = nil) ⇒ Object
51 52 53 54 55 56 57 |
# File 'lib/megam/core/domains.rb', line 51 def created_at(arg=nil) if arg != nil @created_at = arg else @created_at end end |
#domain ⇒ Object
27 28 29 |
# File 'lib/megam/core/domains.rb', line 27 def domain self end |
#for_json ⇒ Object
75 76 77 78 79 80 81 82 |
# File 'lib/megam/core/domains.rb', line 75 def for_json result = { "id" => id, "name" => name, "created_at" => created_at } result end |
#from_hash(o) ⇒ Object
99 100 101 102 103 104 |
# File 'lib/megam/core/domains.rb', line 99 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
31 32 33 34 35 36 37 |
# File 'lib/megam/core/domains.rb', line 31 def id(arg=nil) if arg != nil @id = arg else @id end end |
#name(arg = nil) ⇒ Object
41 42 43 44 45 46 47 |
# File 'lib/megam/core/domains.rb', line 41 def name(arg=nil) if arg != nil @name = arg else @name end end |
#to_hash ⇒ Object
Transform the ruby obj -> to a Hash
62 63 64 65 66 67 68 69 |
# File 'lib/megam/core/domains.rb', line 62 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
71 72 73 |
# File 'lib/megam/core/domains.rb', line 71 def to_json(*a) for_json.to_json(*a) end |
#to_s ⇒ Object
122 123 124 |
# File 'lib/megam/core/domains.rb', line 122 def to_s Megam::Stuff.styled_hash(to_hash) end |