Module: Cyrax::Extensions::HasResource

Extended by:
ActiveSupport::Concern
Included in:
Resource
Defined in:
lib/cyrax/extensions/has_resource.rb

Defined Under Namespace

Modules: ClassMethods

Instance Method Summary collapse

Instance Method Details

#resource_attributesObject



34
35
36
# File 'lib/cyrax/extensions/has_resource.rb', line 34

def resource_attributes
  filter_attributes(dirty_resource_attributes)
end

#resource_classObject

Returns the resource class as a constant - e.g. Product



13
14
15
16
17
18
19
# File 'lib/cyrax/extensions/has_resource.rb', line 13

def resource_class
  if self.resource_class_name
    self.resource_class_name.constantize
  else
    resource_name.classify.constantize
  end
end

#resource_scopeObject

Returns the resource class - e.g. Product If you want your resource to return something interesting, you should override this in your resource by defining the method and returning your own scope

Examples:

Overriding resource_scope

class Products::UserResource < Products::BaseResource
  def resource_scope
    accessor.products
  end
end


30
31
32
# File 'lib/cyrax/extensions/has_resource.rb', line 30

def resource_scope
  resource_class
end

#response_nameObject



38
39
40
# File 'lib/cyrax/extensions/has_resource.rb', line 38

def response_name
  resource_name
end