Class: DNZ::Record

Inherits:
Object
  • Object
show all
Defined in:
lib/dnz/record.rb

Overview

This class is for fetching record metadata from DigitalNZ.

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(client, id) ⇒ Record

Returns a new instance of Record.



14
15
16
17
18
19
20
21
# File 'lib/dnz/record.rb', line 14

def initialize(client, id)
  @client = client
  @id = id

  options = {:id => @id}
  @xml = @client.fetch(:record, options)
  parse_record
end

Dynamic Method Handling

This class handles dynamic methods through the method_missing method

#method_missing(method, *args, &block) ⇒ Object



27
28
29
30
31
32
33
# File 'lib/dnz/record.rb', line 27

def method_missing(method, * args, & block)
  if attribute = document.root.attributes[method.to_s.upcase]
    attribute.to_s
  else
    @data.send(method, * args, & block)
  end
end

Instance Attribute Details

#idObject (readonly)

Returns the value of attribute id.



12
13
14
# File 'lib/dnz/record.rb', line 12

def id
  @id
end

Class Method Details

.find(id) ⇒ Object



8
9
10
# File 'lib/dnz/record.rb', line 8

def self.find(id)
  self.new(Client.connection, id)
end

Instance Method Details

#typeObject



23
24
25
# File 'lib/dnz/record.rb', line 23

def type
  @data['type']
end