lib/dnsimple/extended_attribute.rb in dnsimple-ruby-1.3.2 vs lib/dnsimple/extended_attribute.rb in dnsimple-ruby-1.4.0
- old
+ new
@@ -1,46 +1,52 @@
-class DNSimple::ExtendedAttribute < DNSimple::Base # Used for domains that require extended attributes.
- # An option for an extended attribute
- class Option < DNSimple::Base
- # The option name
- attr_accessor :title
+module DNSimple
- # The option value
- attr_accessor :value
+ # Used for domains that require extended attributes.
+ class ExtendedAttribute < Base
- # A long description of the option
- attr_accessor :description
- end
+ # An option for an extended attribute
+ class Option < Base
+ # The option name
+ attr_accessor :title
- # The extended attribute name
- attr_accessor :name
+ # The option value
+ attr_accessor :value
- # A description of the extended attribute
- attr_accessor :description
+ # A long description of the option
+ attr_accessor :description
+ end
- # Boolean indicating if the extended attribute is required
- attr_accessor :required
+ # The extended attribute name
+ attr_accessor :name
- # An array of options for the extended attribute
- def options
- @options ||= []
- end
+ # A description of the extended attribute
+ attr_accessor :description
- def options=(opts)
- @options = []
- opts.each do |opt|
- @options << DNSimple::ExtendedAttribute::Option.new(opt)
+ # Boolean indicating if the extended attribute is required
+ attr_accessor :required
+
+ # An array of options for the extended attribute
+ def options
+ @options ||= []
end
- end
- # Find the extended attributes for the given TLD
- def self.find(tld, options={})
- response = DNSimple::Client.get "extended_attributes/#{tld}.json", options
+ def options=(opts)
+ @options = []
+ opts.each do |opt|
+ @options << DNSimple::ExtendedAttribute::Option.new(opt)
+ end
+ end
- case response.code
- when 200
- response.map { |r| new(r) }
- else
- raise RuntimeError, "Error: #{response.code}"
+ # Find the extended attributes for the given TLD
+ def self.find(tld, options={})
+ response = DNSimple::Client.get("extended_attributes/#{tld}", options)
+
+ case response.code
+ when 200
+ response.map { |r| new(r) }
+ else
+ raise RequestError.new("Error finding extended attributes", response)
+ end
end
+
end
end