class Megam::Quotas
Public Class Methods
create(params)
click to toggle source
# File lib/megam/core/quotas.rb, line 197 def self.create(params) quo = from_hash(params) quo.create end
from_hash(o)
click to toggle source
# File lib/megam/core/quotas.rb, line 161 def self.from_hash(o) quo = new(o) quo.from_hash(o) quo end
json_create(o)
click to toggle source
# File lib/megam/core/quotas.rb, line 146 def self.json_create(o) quo = new({}) quo.id(o['id']) if o.key?('id') quo.account_id(o["account_id"]) if o.has_key?("account_id") quo.name(o['name']) if o.key?('name') quo.allowed(o['allowed']) if o.key?('allowed') quo.allocated_to(o['allocated_to']) if o.key?('allocated_to') # this will be an array? can hash store array? quo.inputs(o['inputs']) if o.key?('inputs') quo.quota_type(o['quota_type']) if o.key?('quota_type') quo.status(o['status']) if o.key?('status') quo.created_at(o['created_at']) if o.key?('created_at') quo.updated_at(o['updated_at']) if o.key?('updated_at') quo end
list(params)
click to toggle source
# File lib/megam/core/quotas.rb, line 192 def self.list(params) quo = self.new(params) quo.megam_rest.list_quotas end
new(o)
click to toggle source
Calls superclass method
Megam::RestAdapter::new
# File lib/megam/core/quotas.rb, line 3 def initialize(o) @id = nil @account_id = nil @name = nil @cost = nil @allowed = nil @allocated_to = nil @quota_type = nil @status = nil @inputs = [] @created_at = nil @updated_at = nil super(o) end
show(params)
click to toggle source
# File lib/megam/core/quotas.rb, line 182 def self.show(params) quo = new(params) quo.megam_rest.get_one_quota(params['id']) end
update(params)
click to toggle source
# File lib/megam/core/quotas.rb, line 187 def self.update(params) quo = from_hash(params) quo.update end
Public Instance Methods
account_id(arg=nil)
click to toggle source
# File lib/megam/core/quotas.rb, line 30 def account_id(arg=nil) if arg != nil @account_id = arg else @account_id end end
allocated_to(arg = nil)
click to toggle source
# File lib/megam/core/quotas.rb, line 54 def allocated_to(arg = nil) if !arg.nil? @allocated_to = arg else @allocated_to end end
allowed(arg = nil)
click to toggle source
# File lib/megam/core/quotas.rb, line 46 def allowed(arg = nil) if !arg.nil? @allowed = arg else @allowed end end
create()
click to toggle source
# File lib/megam/core/quotas.rb, line 202 def create megam_rest.post_quotas(to_hash) end
created_at(arg = nil)
click to toggle source
# File lib/megam/core/quotas.rb, line 86 def created_at(arg = nil) if !arg.nil? @created_at = arg else @created_at end end
error?()
click to toggle source
# File lib/megam/core/quotas.rb, line 102 def error? crocked = true if some_msg.key?(:msg_type) && some_msg[:msg_type] == 'error' end
for_json()
click to toggle source
# File lib/megam/core/quotas.rb, line 129 def for_json result = { 'id' => id, 'account_id' => account_id, 'name' => name, 'allowed' => allowed, 'allocated_to' => allocated_to, 'inputs' => inputs, 'quota_type' => quota_type, 'status' => status, 'created_at' => created_at, 'updated_at' => updated_at } result end
from_hash(o)
click to toggle source
# File lib/megam/core/quotas.rb, line 167 def from_hash(o) @id = o['id'] if o.key?('id') @account_id = o["account_id"] if o.has_key?("account_id") @name = o['name'] if o.key?('name') @allowed = o['allowed'] if o.key?('allowed') @allocated_to = o['allocated_to'] if o.key?('allocated_to') @inputs = o['inputs'] if o.key?('inputs') @quota_type = o['quota_type'] if o.key?('quota_type') @status = o['status'] if o.key?('status') @created_at = o['created_at'] if o.key?('created_at') @updated_at = o['updated_at'] if o.key?('updated_at') self end
id(arg = nil)
click to toggle source
# File lib/megam/core/quotas.rb, line 22 def id(arg = nil) if !arg.nil? @id = arg else @id end end
inputs(arg = [])
click to toggle source
# File lib/megam/core/quotas.rb, line 62 def inputs(arg = []) if arg != [] @inputs = arg else @inputs end end
name(arg = nil)
click to toggle source
# File lib/megam/core/quotas.rb, line 38 def name(arg = nil) if !arg.nil? @name = arg else @name end end
quota_type(arg = nil)
click to toggle source
# File lib/megam/core/quotas.rb, line 70 def quota_type(arg = nil) if !arg.nil? @quota_type = arg else @quota_type end end
quotas()
click to toggle source
# File lib/megam/core/quotas.rb, line 18 def quotas self end
status(arg = nil)
click to toggle source
# File lib/megam/core/quotas.rb, line 78 def status(arg = nil) if !arg.nil? @status = arg else @status end end
to_hash()
click to toggle source
Transform the ruby obj -> to a Hash
# File lib/megam/core/quotas.rb, line 107 def to_hash index_hash = {} index_hash['json_claz'] = self.class.name index_hash['id'] = id index_hash["account_id"] = account_id index_hash['name'] = name index_hash['allowed'] = allowed index_hash['allocated_to'] = allocated_to index_hash['quota_type'] = quota_type index_hash['status'] = status index_hash['inputs'] = inputs index_hash['created_at'] = created_at index_hash['updated_at'] = updated_at 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/quotas.rb, line 125 def to_json(*a) for_json.to_json(*a) end
to_s()
click to toggle source
# File lib/megam/core/quotas.rb, line 211 def to_s Megam::Stuff.styled_hash(to_hash) end
update()
click to toggle source
Create the node via the REST API
# File lib/megam/core/quotas.rb, line 207 def update megam_rest.update_quotas(to_hash) end
updated_at(arg = nil)
click to toggle source
# File lib/megam/core/quotas.rb, line 94 def updated_at(arg = nil) if !arg.nil? @updated_at = arg else @updated_at end end