class Megam::GogsAccount

Public Class Methods

create(o) click to toggle source
# File lib/megam/core/gogs_account.rb, line 198
def self.create(o)
  acct = from_hash(o)
  acct.create
end
from_hash(o) click to toggle source
# File lib/megam/core/gogs_account.rb, line 179
def self.from_hash(o)
  acct = self.new(o[:name], o[:displayName], o[:mail], o[:password])
  acct.from_hash(o)
  acct
end
json_create(o) click to toggle source

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

# File lib/megam/core/gogs_account.rb, line 161
def self.json_create(o)
  acct = new
  acct.creationDate(o["creationDate"]) if o.has_key?("creationDate")
  acct.admin(o["admin"]) if o.has_key?("admin")
  acct.type(o["type"]) if o.has_key?("type")
  acct.password(o["password"]) if o.has_key?("password")
  acct.name(o["name"]) if o.has_key?("name")
  acct.mail(o["mail"]) if o.has_key?("mail")
  acct.displayName(o["displayName"]) if o.has_key?("displayName]")
  acct.lastModified(o["lastModifiec"]) if o.has_key?("lastModified")
  acct.active(o["active"]) if o.has_key?("active")
  acct.some_msg[:status] = o["status"] if o.has_key?("status")
  acct.some_msg[:msg_type] = o["msg_type"] if o.has_key?("msg_type")
  acct.some_msg[:msg]= o["msg"] if o.has_key?("msg")
  acct.some_msg[:links] = o["links"] if o.has_key?("links")
  acct
end
new(name=nil, displayName=nil, mail=nil, password=nil) click to toggle source
Calls superclass method
# File lib/megam/core/gogs_account.rb, line 19
def initialize(name=nil, displayName=nil, mail=nil, password=nil)
  @creationDate = nil
  @admin = nil
  @type = nil
  @password = nil
  @name = nil
  @mail = nil
  @displayName = nil
  @lastModified = nil
  @active = nil
  @some_msg = {}
  super(name, displayName, mail, password)
end
show(name, displayName, mail, password) click to toggle source

Load a account by email_p

# File lib/megam/core/gogs_account.rb, line 204
def self.show(name, displayName, mail, password)
  acct = self.new(name, displayName, mail, password)
  acct.megam_rest.get_accounts(mail)
end

Public Instance Methods

account() click to toggle source

used by resque workers and any other background job

# File lib/megam/core/gogs_account.rb, line 34
def account
  self
end
active(arg=nil) click to toggle source
# File lib/megam/core/gogs_account.rb, line 102
def active(arg=nil)
  if arg != nil
    @active = arg
  else
  @active
  end
end
admin(arg=nil) click to toggle source
# File lib/megam/core/gogs_account.rb, line 46
def admin(arg=nil)
  if arg != nil
    @admin = arg
  else
  @admin
  end
end
create() click to toggle source

Create the node via the REST API

# File lib/megam/core/gogs_account.rb, line 210
def create
  megam_rest.post_accounts(to_hash)
end
creationDate(arg=nil) click to toggle source
# File lib/megam/core/gogs_account.rb, line 38
def creationDate(arg=nil)
  if arg != nil
    @creationDate = arg
  else
  @creationDate
  end
end
displayName(arg=nil) click to toggle source
# File lib/megam/core/gogs_account.rb, line 86
def displayName(arg=nil)
  if arg != nil
    @displayName = arg
  else
  @displayName
  end
end
error?() click to toggle source
# File lib/megam/core/gogs_account.rb, line 118
def error?
  crocked  = true if (some_msg.has_key?(:msg_type) && some_msg[:msg_type] == "error")
end
for_json() click to toggle source
# File lib/megam/core/gogs_account.rb, line 145
def for_json
  result = {
    "creationDate" => creationDate,
    "admin" => admin,
    "type" => type,
    "password" => password,
    "name" => name,
    "mail" => mail,
    "displayName" => displayName,
    "lastModified" => lastModified,
    "active" => active
  }
  result
end
from_hash(o) click to toggle source
# File lib/megam/core/gogs_account.rb, line 185
def from_hash(o)
  @creationDate        = o[:creationDate] if o.has_key?(:creationDate)
  @admin     = o[:admin] if o.has_key?(:admin)
  @type   = o[:type] if o.has_key?(:type)
  @password = o[:password] if o.has_key?(:password)
  @name = o[:name] if o.has_key?(:name)
  @mail = o[:mail] if o.has_key?(:mail)
  @displayName = o[:displayName] if o.has_key?(:displayName)
  @lastModified = o[:lastModified] if o.has_key?(:lastModified)
  @active = o[:active] if o.has_key?(:active)
  self
end
lastModified(arg=nil) click to toggle source
# File lib/megam/core/gogs_account.rb, line 94
def lastModified(arg=nil)
  if arg != nil
    @lastModified = arg
  else
  @lastModified
  end
end
mail(arg=nil) click to toggle source
# File lib/megam/core/gogs_account.rb, line 78
def mail(arg=nil)
  if arg != nil
    @mail = arg
  else
  @mail
  end
end
name(arg=nil) click to toggle source
# File lib/megam/core/gogs_account.rb, line 70
def name(arg=nil)
   if arg != nil
     @name = arg
   else
   @name
   end
 end
password(arg=nil) click to toggle source
# File lib/megam/core/gogs_account.rb, line 62
def password(arg=nil)
   if arg != nil
     @password = arg
   else
   @password
   end
 end
some_msg(arg=nil) click to toggle source
# File lib/megam/core/gogs_account.rb, line 110
def some_msg(arg=nil)
  if arg != nil
    @some_msg = arg
  else
  @some_msg
  end
end
to_hash() click to toggle source

Transform the ruby obj -> to a Hash

# File lib/megam/core/gogs_account.rb, line 123
def to_hash
  index_hash = Hash.new
  index_hash["json_claz"] = self.class.name
  index_hash["creationDate"] = creationDate
  index_hash["admin"] = admin
  index_hash["type"] = type
  index_hash["password"] = password
  index_hash["name"] = name
  index_hahs["mail"] = mail
  index_hash["displayName"] = displayName
  index_hash["lastModified"] = lastModified
  index_hash["active"] = active
  index_hash["some_msg"] = some_msg
  index_hash
end
to_json(*a) click to toggle source

Serialize this object as a hash: called from JsonCompat. Verify if this called from JsonCompat during testing.

# File lib/megam/core/gogs_account.rb, line 141
def to_json(*a)
  for_json.to_json(*a)
end
to_s() click to toggle source
# File lib/megam/core/gogs_account.rb, line 214
def to_s
  Megam::Stuff.styled_hash(to_hash)
end
type(arg=nil) click to toggle source
# File lib/megam/core/gogs_account.rb, line 54
def type(arg=nil)
   if arg != nil
     @type = arg
   else
   @type
   end
 end