lib/conglomerate/serializer.rb in conglomerate-0.2.0 vs lib/conglomerate/serializer.rb in conglomerate-0.2.1
- old
+ new
@@ -28,14 +28,18 @@
def apply_version(collection)
collection.merge({"version" => "1.0"})
end
def apply_href(collection, proc: self.class._href, object: nil)
- if object
- collection.merge({"href" => context.instance_exec(object, &proc)})
+ if proc
+ if object
+ collection.merge({"href" => context.instance_exec(object, &proc)})
+ else
+ collection.merge({"href" => context.instance_eval(&proc)})
+ end
else
- collection.merge({"href" => context.instance_eval(&proc)})
+ collection
end
end
def apply_data(collection, data: [], object: nil)
data = data.map do |name|
@@ -187,10 +191,10 @@
end
attr_writer :_href, :_item_href, :_queries, :_attributes, :_links
def _href
- @_href || Proc.new { raise ArgumentError, "You must include an href" }
+ @_href || nil
end
def _item_href
@_item_href || nil
end