lib/ivy/serializers/mapping.rb in ivy-serializers-0.3.0 vs lib/ivy/serializers/mapping.rb in ivy-serializers-0.4.0
- old
+ new
@@ -3,17 +3,17 @@
module Ivy
module Serializers
class Mapping
def initialize(klass)
- @attrs = {}
+ @attributes = {}
@relationships = {}
@klass = klass
end
def attribute(name, &block)
- @attrs[name] = Attribute.new(name, &block)
+ @attributes[name] = Attribute.new(name, &block)
end
def attributes(*names)
names.each { |name| attribute(name) }
end
@@ -21,11 +21,11 @@
def belongs_to(name, options={}, &block)
@relationships[name] = Relationships::BelongsTo.new(name, options, &block)
end
def generate_attributes(generator, resource)
- @attrs.each_value { |attr| attr.generate(generator, resource) }
+ @attributes.each_value { |attribute| attribute.generate(generator, resource) }
end
def has_many(name, options={}, &block)
@relationships[name] = Relationships::HasMany.new(name, options, &block)
end
@@ -33,10 +33,10 @@
def relationships(generator, resource)
@relationships.each_value { |relationship| relationship.generate(generator, resource) }
end
def resource(generator, resource)
- generator.attributes(resource) unless @attrs.empty?
+ generator.attributes(resource) unless @attributes.empty?
generator.relationships(resource) unless @relationships.empty?
end
end
end
end