class JsonApiClient::Schema

Constants

Property

Public Class Methods

new() click to toggle source
# File lib/json_api_client/schema.rb, line 108
def initialize
  @properties = {}
end
register(type_hash) click to toggle source
# File lib/json_api_client/schema.rb, line 149
def register(type_hash)
  TypeFactory.register(type_hash)
end

Public Instance Methods

[](property_name)
Alias for: find
add(name, options) click to toggle source

Add a property to the schema

@param name [Symbol] the name of the property @param options [Hash] property options @option options [Symbol] :type The property type @option options [Symbol] :default The default value for the property @return [void]

# File lib/json_api_client/schema.rb, line 119
def add(name, options)
  @properties[name.to_sym] = Property.new(name.to_sym, options[:type], options[:default])
end
each(&block)
Alias for: each_property
each_property(&block) click to toggle source
# File lib/json_api_client/schema.rb, line 132
def each_property(&block)
  @properties.values.each(&block)
end
Also aliased as: each
find(property_name) click to toggle source

Look up a property by name

@param property_name [String] the name of the property @return [Property, nil] the property definition for property_name or nil

# File lib/json_api_client/schema.rb, line 142
def find(property_name)
  @properties[property_name.to_sym]
end
Also aliased as: []
length()
Alias for: size
size() click to toggle source

How many properties are defined

@return [Fixnum] the number of defined properties

# File lib/json_api_client/schema.rb, line 126
def size
  @properties.size
end
Also aliased as: length