lib/jsonapi/basic_resource.rb in jsonapi-resources-0.10.0.beta5 vs lib/jsonapi/basic_resource.rb in jsonapi-resources-0.10.0.beta6
- old
+ new
@@ -363,11 +363,11 @@
end
end
@reload_needed = true
else
- @model.public_send(relationship.relation_name(context: @context)).destroy(key)
+ @model.public_send(relationship.relation_name(context: @context)).delete(key)
end
:completed
rescue ActiveRecord::DeleteRestrictionError => e
@@ -446,10 +446,13 @@
unless subclass._attributes[:id]
subclass.attribute :id, format: :id, readonly: true
end
check_reserved_resource_name(subclass._type, subclass.name)
+
+ subclass._routed = false
+ subclass._warned_missing_route = false
end
def rebuild_relationships(relationships)
original_relationships = relationships.deep_dup
@@ -492,11 +495,11 @@
else
model_name.rpartition('/').last
end
end
- attr_accessor :_attributes, :_relationships, :_type, :_model_hints
+ attr_accessor :_attributes, :_relationships, :_type, :_model_hints, :_routed, :_warned_missing_route
attr_writer :_allowed_filters, :_paginator, :_allowed_sort
def create(context)
new(create_model, context)
end
@@ -958,24 +961,28 @@
def mutable?
!@immutable
end
- def exclude_links(exclude)
+ def parse_exclude_links(exclude)
case exclude
when :default, "default"
- @_exclude_links = [:self]
+ [:self]
when :none, "none"
- @_exclude_links = []
+ []
when Array
- @_exclude_links = exclude.collect {|link| link.to_sym}
+ exclude.collect {|link| link.to_sym}
else
fail "Invalid exclude_links"
end
end
+ def exclude_links(exclude)
+ @_exclude_links = parse_exclude_links(exclude)
+ end
+
def _exclude_links
- @_exclude_links ||= []
+ @_exclude_links ||= parse_exclude_links(JSONAPI.configuration.default_exclude_links)
end
def exclude_link?(link)
_exclude_links.include?(link.to_sym)
end