Class: Ivy::Serializers::Registry

Inherits:
Object
  • Object
show all
Defined in:
lib/ivy/serializers/registry.rb

Instance Method Summary collapse

Constructor Details

#initializeRegistry

Returns a new instance of Registry.



6
7
8
# File 'lib/ivy/serializers/registry.rb', line 6

def initialize
  @mappings = Hash.new { |hash, klass| hash[klass] = new_mapping(klass) }
end

Instance Method Details

#attributes(generator, resource) ⇒ Object



10
11
12
# File 'lib/ivy/serializers/registry.rb', line 10

def attributes(generator, resource)
  mapping_for(resource.class).generate_attributes(generator, resource)
end

#map(klass, &block) ⇒ Object



14
15
16
# File 'lib/ivy/serializers/registry.rb', line 14

def map(klass, &block)
  mapping_for(klass).instance_eval(&block)
end

#relationships(generator, resource) ⇒ Object



18
19
20
# File 'lib/ivy/serializers/registry.rb', line 18

def relationships(generator, resource)
  mapping_for(resource.class).relationships(generator, resource)
end

#resource(generator, resource) ⇒ Object



22
23
24
# File 'lib/ivy/serializers/registry.rb', line 22

def resource(generator, resource)
  mapping_for(resource.class).resource(generator, resource)
end