class Mio::Model::AccountProperty

Public Instance Methods

create_hash() click to toggle source
# File lib/mio/model/account_property.rb, line 12
def create_hash
  {key: @args.key,
   value: ERB.new(@args.value).result}
end
go() click to toggle source
# File lib/mio/model/account_property.rb, line 25
def go
  @object = look_up
  if @object.nil?
    @object = create
  elsif  ((@object != nil) && (@object['value'] != @args.value))
    @client.remove self.class.resource_name, @object['id']
    @object = create
  end

  @object['name'] = @args.name
  @object['id'] = @object['href'].scan( /\d+$/).last

  return @object
end
look_up() click to toggle source
# File lib/mio/model/account_property.rb, line 17
def look_up
  r = self.class.resource_name
  all_resources = @client.find_all r
  return nil if all_resources['totalCount'] == 0

  all_resources[r].find{|o| o['key'] == @args.key}
end