Class: Mio::Model::AccountProperty
Instance Attribute Summary
Attributes inherited from Mio::Model
#args, #client, #search
Instance Method Summary
collapse
Methods inherited from Mio::Model
#configure, #create, field, #initialize, mappings, nested, #set_enable, set_resource, #set_start, #validate
Constructor Details
This class inherits a constructor from Mio::Model
Instance Method Details
#create_hash ⇒ Object
12
13
14
15
|
# File 'lib/mio/model/account_property.rb', line 12
def create_hash
{key: @args.key,
value: ERB.new(@args.value).result}
end
|
#go ⇒ Object
25
26
27
28
29
30
31
32
33
34
35
36
37
38
|
# 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 ⇒ Object
17
18
19
20
21
22
23
|
# 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
|