class Megam::Domains

Public Class Methods

create(o) click to toggle source
# File lib/megam/core/domains.rb, line 96
def self.create(o)
    dom = from_hash(o)
    dom.create
end
from_hash(o) click to toggle source
# File lib/megam/core/domains.rb, line 81
def self.from_hash(o)
    org = self.new(o)
    org.from_hash(o)
    org
end
json_create(o) click to toggle source

Create a Megam::Domains from JSON (used by the backgroud job workers)

# File lib/megam/core/domains.rb, line 72
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) click to toggle source
# File lib/megam/core/domains.rb, line 101
def self.list(o)
    dom = from_hash(o)
    dom.megam_rest.get_domains
end
new(o) click to toggle source
Calls superclass method Megam::RestAdapter::new
# File lib/megam/core/domains.rb, line 3
def initialize(o)
    @id = nil
    @org_id = nil
    @name = nil
    @created_at = nil
    super(o)
end

Public Instance Methods

create() click to toggle source
# File lib/megam/core/domains.rb, line 106
def create
    megam_rest.post_domains(to_hash)
end
created_at(arg=nil) click to toggle source
# File lib/megam/core/domains.rb, line 39
def created_at(arg=nil)
    if arg != nil
        @created_at = arg
    else
        @created_at
    end
end
domain() click to toggle source
# File lib/megam/core/domains.rb, line 11
def domain
    self
end
for_json() click to toggle source
# File lib/megam/core/domains.rb, line 61
def for_json
    result = {
        "id" => id,
        "org_id" => org_id,
        "name" => name,
        "created_at" => created_at
    }
    result
end
from_hash(o) click to toggle source
# File lib/megam/core/domains.rb, line 88
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) click to toggle source
# File lib/megam/core/domains.rb, line 15
def id(arg=nil)
    if arg != nil
        @id = arg
    else
        @id
    end
end
name(arg=nil) click to toggle source
# File lib/megam/core/domains.rb, line 31
def name(arg=nil)
    if arg != nil
        @name = arg
    else
        @name
    end
end
org_id(arg=nil) click to toggle source
# File lib/megam/core/domains.rb, line 22
        def org_id(arg=nil)
    if arg != nil
        @org_id = arg
    else
        @org_id
    end
end
show() click to toggle source
# File lib/megam/core/domains.rb, line 110
def show
    megam_rest.get_domains(to_hash)
end
to_hash() click to toggle source
# File lib/megam/core/domains.rb, line 47
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) click to toggle source
# File lib/megam/core/domains.rb, line 57
def to_json(*a)
    for_json.to_json(*a)
end
to_s() click to toggle source
# File lib/megam/core/domains.rb, line 114
def to_s
    Megam::Stuff.styled_hash(to_hash)
end