Class: DNZ::Record
- Inherits:
-
Object
- Object
- DNZ::Record
- Defined in:
- lib/dnz/record.rb
Overview
This class is for fetching record metadata from DigitalNZ.
Instance Attribute Summary collapse
-
#id ⇒ Object
readonly
Returns the value of attribute id.
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize(client, id) ⇒ Record
constructor
A new instance of Record.
- #method_missing(method, *args, &block) ⇒ Object
- #type ⇒ Object
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 = {:id => @id} @xml = @client.fetch(:record, ) 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
#id ⇒ Object (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
#type ⇒ Object
23 24 25 |
# File 'lib/dnz/record.rb', line 23 def type @data['type'] end |