class Ivy::Serializers::Registry

Public Class Methods

new() click to toggle source
# File lib/ivy/serializers/registry.rb, line 6
def initialize
  @mappings = Hash.new { |hash, klass| hash[klass] = new_mapping(klass) }
end

Public Instance Methods

attributes(generator, resource) click to toggle source
# File lib/ivy/serializers/registry.rb, line 10
def attributes(generator, resource)
  mapping_for(resource.class).generate_attributes(generator, resource)
end
map(klass, &block) click to toggle source
# File lib/ivy/serializers/registry.rb, line 14
def map(klass, &block)
  mapping_for(klass).instance_eval(&block)
end
relationships(generator, resource) click to toggle source
# File lib/ivy/serializers/registry.rb, line 18
def relationships(generator, resource)
  mapping_for(resource.class).relationships(generator, resource)
end
resource(generator, resource) click to toggle source
# File lib/ivy/serializers/registry.rb, line 22
def resource(generator, resource)
  mapping_for(resource.class).resource(generator, resource)
end

Private Instance Methods

mapping_for(klass) click to toggle source
# File lib/ivy/serializers/registry.rb, line 28
def mapping_for(klass)
  @mappings[klass]
end
new_mapping(klass) click to toggle source
# File lib/ivy/serializers/registry.rb, line 32
def new_mapping(klass)
  Mapping.new(klass)
end