class Recurly::Schema::Attribute

Constants

PRIMITIVE_TYPES

Attributes

type[R]

The type of the attribute. Might be a class like ‘DateTime` or could be a Recurly object. In this case a symbol should be used. Example: :Account. To get the Recurly type use recurly_class @return [Class,Symbol]

Public Class Methods

build(type, options = {}) click to toggle source
# File lib/recurly/schema.rb, line 69
def self.build(type, options = {})
  if PRIMITIVE_TYPES.include? type
    PrimitiveAttribute.new(type)
  elsif type == :Boolean
    BooleanAttribute.new
  elsif type == DateTime
    DateTimeAttribute.new
  elsif type.is_a? Symbol
    ResourceAttribute.new(type)
  elsif type == Array
    item_attr = build(options[:item_type])
    ArrayAttribute.new(item_attr)
  else
    throw ArgumentError
  end
end
new(type = nil) click to toggle source
# File lib/recurly/schema.rb, line 86
def initialize(type = nil)
  @type = type
end

Public Instance Methods

cast(value) click to toggle source
# File lib/recurly/schema.rb, line 90
def cast(value)
  value
end
recurly_class() click to toggle source
# File lib/recurly/schema.rb, line 94
def recurly_class
  @recurly_class ||= Schema.get_recurly_class(type)
end