module Cyrax::Extensions::HasResource::ClassMethods

Public Instance Methods

accessible_attributes(*attrs) click to toggle source

Class method for setting all the attributes that you want to access in the resource

@example

accessible_attributes :description, :model, :price_in_cents, :vendor

@param attrs [Array(Symbol)] Symbols of the attributes

# File lib/cyrax/extensions/has_resource.rb, line 37
def accessible_attributes(*attrs)
  if attrs.blank?
    @accessible_attributes || []
  else
    @accessible_attributes ||= []
    @accessible_attributes += attrs
  end
end
resource(name, options = {}) click to toggle source

Class method for setting the resource that you want to access

@example

resource :product

@param name [Symbol] The name of the resource @param options Hash [Hash] Options

# File lib/cyrax/extensions/has_resource.rb, line 53
def resource(name, options = {})
  if options[:class_name].present?
    ActiveSupport::Deprecation.warn "sending :class_name in #resource method is deprecated. send :class instead"
    options[:class] = options[:class_name].to_s.constantize
  end
  self._resource_name = name.to_s
  self._resource_class = options[:class]
  self._collection_name = name.to_s.pluralize
end