Class: Gaah::Resource::Resource

Inherits:
ApiModel
  • Object
show all
Defined in:
lib/gaah/resource/resource.rb

Instance Attribute Summary collapse

Attributes inherited from ApiModel

#id

Instance Method Summary collapse

Methods inherited from ApiModel

#==, batch_create

Constructor Details

#initialize(xml) ⇒ Resource

Returns a new instance of Resource.



6
7
8
9
10
11
12
13
14
15
16
17
# File 'lib/gaah/resource/resource.rb', line 6

def initialize(xml)
  store_xml(xml)

  @id = inner_text(:id)
  (@xml/'apps|property').each do |property|
    case property.attributes['name'].value
    when 'resourceCommonName' then @name  = property.attributes['value'].value
    when 'resourceEmail'      then @email = property.attributes['value'].value
    when 'resourceType'       then @type  = property.attributes['value'].value
    end
  end
end

Instance Attribute Details

#emailObject (readonly)

Returns the value of attribute email.



4
5
6
# File 'lib/gaah/resource/resource.rb', line 4

def email
  @email
end

#nameObject (readonly)

Returns the value of attribute name.



4
5
6
# File 'lib/gaah/resource/resource.rb', line 4

def name
  @name
end

#typeObject (readonly)

Returns the value of attribute type.



4
5
6
# File 'lib/gaah/resource/resource.rb', line 4

def type
  @type
end

Instance Method Details

#marshal_dumpObject



28
29
30
# File 'lib/gaah/resource/resource.rb', line 28

def marshal_dump
  [@id, @name, @email, @type]
end

#marshal_load(array) ⇒ Object



32
33
34
# File 'lib/gaah/resource/resource.rb', line 32

def marshal_load(array)
  @id, @name, @email, @type = array
end

#to_json(*args) ⇒ Object



19
20
21
22
23
24
25
26
# File 'lib/gaah/resource/resource.rb', line 19

def to_json(*args)
  {
    id: @id,
    name: @name,
    email: @email,
    type: @type,
  }.to_json
end