class Recurly::Schema
The class responsible for describing a schema. This is used for requests and resources.
Attributes
The attributes in the schema @return [Hash<String,Attribute>]
Public Class Methods
Source
# File lib/recurly/schema.rb, line 41 def self.get_recurly_class(type) raise ArgumentError, "#{type.inspect} must be a symbol but is a #{type.class}" unless type.is_a?(Symbol) if type == :Address Recurly::Resources::Address elsif Recurly::Requests.const_defined?(type, false) Recurly::Requests.const_get(type, false) elsif Recurly::Resources.const_defined?(type, false) Recurly::Resources.const_get(type, false) else raise ArgumentError, "Recurly type '#{type}' is unknown" end end
Gets a recurly class given a symbol name.
@example
Schema.get_recurly_class(:Account) #=> Recurly::Resources::Account
@param type [Symbol] The name of the class you wish to find @return [Request,Resource] @raise ArgumentError If class can’t be found.
Public Instance Methods
Source
# File lib/recurly/schema.rb, line 18 def add_attribute(name, type, options) attribute = Attribute.build(type, options) @attributes[name.to_s] = attribute attribute end
Adds an attribute to the schema definition
@param name [Symbol] The name of the attribute @param type [Class,Symbol] The type of the attribute. Use capitalized symbol for Recurly
class. Example: :Account. @param options [Schema::Attribute] The created and registered attribute object.
Source
# File lib/recurly/schema.rb, line 28 def get_attribute(name) @attributes[name.to_s] end
Gets an attribute from this schema given a name
@param name [String,Symbol] The name/key of the attribute @return [Attribute,nil] The found Attribute
. nil if not found.