Class: Chemtrail::Resource

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

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(id, type) ⇒ Resource

Returns a new instance of Resource.



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

def initialize(id, type)
  @id = id
  @type = type
end

Instance Attribute Details

#idObject (readonly)

Returns the value of attribute id.



2
3
4
# File 'lib/chemtrail/resource.rb', line 2

def id
  @id
end

#typeObject (readonly)

Returns the value of attribute type.



2
3
4
# File 'lib/chemtrail/resource.rb', line 2

def type
  @type
end

Instance Method Details

#propertiesObject



13
14
15
# File 'lib/chemtrail/resource.rb', line 13

def properties
  @properties ||= Chemtrail::PropertyList.new
end

#to_hashObject



17
18
19
20
21
22
23
24
# File 'lib/chemtrail/resource.rb', line 17

def to_hash
  {
    id => {
      "Type" => type,
      "Properties" => properties.to_hash
    }
  }
end

#to_referenceObject



9
10
11
# File 'lib/chemtrail/resource.rb', line 9

def to_reference
  { "Ref" => id }
end