Class: Ivy::Serializers::Registry
- Inherits:
-
Object
- Object
- Ivy::Serializers::Registry
- Defined in:
- lib/ivy/serializers/registry.rb
Instance Method Summary collapse
- #attributes(generator, resource) ⇒ Object
-
#initialize ⇒ Registry
constructor
A new instance of Registry.
- #map(klass, &block) ⇒ Object
- #relationships(generator, resource) ⇒ Object
- #resource(generator, resource) ⇒ Object
Constructor Details
#initialize ⇒ Registry
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 |