lib/jsonapi/resource.rb in jsonapi-resources-0.0.5 vs lib/jsonapi/resource.rb in jsonapi-resources-0.0.6
- old
+ new
@@ -1,9 +1,8 @@
require 'jsonapi/configuration'
require 'jsonapi/resource_for'
require 'jsonapi/association'
-require 'action_dispatch/routing/mapper'
module JSONAPI
class Resource
include ResourceFor
@@ -106,12 +105,12 @@
end
raise JSONAPI::Exceptions::ValidationErrors.new(errors)
end
# Override this on a resource instance to override the fetchable keys
- def fetchable(keys, context = nil)
- keys
+ def fetchable_fields(context)
+ self.class.fields
end
class << self
def inherited(base)
base._attributes = (_attributes || {}).dup
@@ -182,19 +181,19 @@
@_key = key.to_sym
end
# Override in your resource to filter the updateable keys
def updateable_fields(context)
- fields
+ _updateable_associations | _attributes.keys
end
# Override in your resource to filter the createable keys
def createable_fields(context)
- fields
+ _updateable_associations | _attributes.keys
end
def fields
- _updateable_associations | _attributes.keys
+ _associations.keys | _attributes.keys
end
# Override this method if you have more complex requirements than this basic find method provides
def find(filters, context = nil)
includes = []