Class: DNSimple::ExtendedAttribute

Inherits:
Object
  • Object
show all
Includes:
HTTParty
Defined in:
lib/dnsimple/extended_attribute.rb

Overview

Used for domains that require extended attributes.

Defined Under Namespace

Classes: Option

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(attributes) ⇒ ExtendedAttribute

:nodoc:



36
37
38
39
40
41
# File 'lib/dnsimple/extended_attribute.rb', line 36

def initialize(attributes)
  attributes.each do |key, value|
    m = "#{key}=".to_sym
    self.send(m, value) if self.respond_to?(m)
  end
end

Instance Attribute Details

#descriptionObject

A description of the extended attribute



30
31
32
# File 'lib/dnsimple/extended_attribute.rb', line 30

def description
  @description
end

#nameObject

The extended attribute name



27
28
29
# File 'lib/dnsimple/extended_attribute.rb', line 27

def name
  @name
end

#requiredObject

Boolean indicating if the extended attribute is required



33
34
35
# File 'lib/dnsimple/extended_attribute.rb', line 33

def required
  @required
end

Class Method Details

.find(tld, options = {}) ⇒ Object

Find the extended attributes for the given TLD



56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
# File 'lib/dnsimple/extended_attribute.rb', line 56

def self.find(tld, options={})
  options.merge!({:basic_auth => Client.credentials})
  
  response = self.get("#{Client.base_uri}/extended_attributes/#{tld}.json", options)

  pp response if Client.debug?

  case response.code
  when 200
    response.map { |r| ExtendedAttribute.new(r) }
  when 401
    raise RuntimeError, "Authentication failed"
  else
    raise RuntimeError, "Error: #{response.code}"
  end
end

Instance Method Details

#optionsObject

An array of options for the extended attribute



44
45
46
# File 'lib/dnsimple/extended_attribute.rb', line 44

def options
  @options ||= []
end

#options=(opts) ⇒ Object



48
49
50
51
52
53
# File 'lib/dnsimple/extended_attribute.rb', line 48

def options=(opts)
  @options = []
  opts.each do |opt|
    @options << Option.new(opt)
  end
end