class Megam::Organizations
Public Class Methods
create(o)
click to toggle source
# File lib/megam/core/organizations.rb, line 109 def self.create(o) org = from_hash(o) org.create end
from_hash(o)
click to toggle source
# File lib/megam/core/organizations.rb, line 94 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::Organization from JSON (used by the backgroud job workers)
# File lib/megam/core/organizations.rb, line 84 def self.json_create(o) org = new({}) org.id(o["id"]) if o.has_key?("id") org.name(o["name"]) if o.has_key?("name") org.accounts_id(o["accounts_id"]) if o.has_key?("accounts_id") org.related_orgs(o["related_orgs"]) if o.has_key?("related_orgs") org.created_at(o["created_at"]) if o.has_key?("created_at") org end
list(o)
click to toggle source
# File lib/megam/core/organizations.rb, line 128 def self.list(o) org = from_hash(o) org.megam_rest.get_organizations end
new(o)
click to toggle source
Calls superclass method
Megam::RestAdapter::new
# File lib/megam/core/organizations.rb, line 3 def initialize(o) @id = nil @name = nil @accounts_id = nil @related_orgs = [] @created_at = nil super(o) end
show(o)
click to toggle source
# File lib/megam/core/organizations.rb, line 114 def self.show(o) org = from_hash(o) org.megam_rest.get_organizations(email) end
update(o)
click to toggle source
# File lib/megam/core/organizations.rb, line 119 def self.update(o) org = from_hash(o) org.update end
Public Instance Methods
accounts_id(arg=nil)
click to toggle source
# File lib/megam/core/organizations.rb, line 24 def accounts_id(arg=nil) if arg != nil @accounts_id = arg else @accounts_id end end
create()
click to toggle source
# File lib/megam/core/organizations.rb, line 133 def create megam_rest.post_organization(to_hash) end
created_at(arg=nil)
click to toggle source
# File lib/megam/core/organizations.rb, line 48 def created_at(arg=nil) if arg != nil @created_at = arg else @created_at end end
for_json()
click to toggle source
# File lib/megam/core/organizations.rb, line 72 def for_json result = { "id" => id, "name" => name, "accounts_id" => accounts_id, "related_orgs" => related_orgs, "created_at" => created_at } result end
from_hash(o)
click to toggle source
# File lib/megam/core/organizations.rb, line 100 def from_hash(o) @id = o[:id] if o.has_key?(:id) @name = o[:name] if o.has_key?(:name) @accounts_id = o[:accounts_id] if o.has_key?(:accounts_id) @related_orgs = o[:related_orgs] if o.has_key?(:related_orgs) @created_at = o[:created_at] if o.has_key?(:created_at) self end
id(arg=nil)
click to toggle source
# File lib/megam/core/organizations.rb, line 16 def id(arg=nil) if arg != nil @id = arg else @id end end
name(arg=nil)
click to toggle source
# File lib/megam/core/organizations.rb, line 32 def name(arg=nil) if arg != nil @name = arg else @name end end
organization()
click to toggle source
# File lib/megam/core/organizations.rb, line 12 def organization self end
to_hash()
click to toggle source
Transform the ruby obj -> to a Hash
# File lib/megam/core/organizations.rb, line 57 def to_hash index_hash = Hash.new index_hash["json_claz"] = self.class.name index_hash["id"] = id index_hash["name"] = name index_hash["accounts_id"] = accounts_id index_hash["related_orgs"] = related_orgs index_hash["created_at"] = created_at index_hash end
to_json(*a)
click to toggle source
# File lib/megam/core/organizations.rb, line 68 def to_json(*a) for_json.to_json(*a) end
to_s()
click to toggle source
# File lib/megam/core/organizations.rb, line 137 def to_s Megam::Stuff.styled_hash(to_hash) end
update()
click to toggle source
# File lib/megam/core/organizations.rb, line 124 def update megam_rest.update_organization(to_hash) end