class SingularResource::Strategy

Attributes

controller[R]
inflector[W]
model[W]
name[R]
options[R]

Public Class Methods

new(controller, name, options={}) click to toggle source
# File lib/singular_resource/strategy.rb, line 8
def initialize(controller, name, options={})
  @controller, @name, @options = controller, name.to_s, options
end

Public Instance Methods

resource() click to toggle source
# File lib/singular_resource/strategy.rb, line 12
def resource
  raise 'Implement in subclass'
end

Protected Instance Methods

inflector() click to toggle source
# File lib/singular_resource/strategy.rb, line 18
def inflector
  @inflector ||= SingularResource::Inflector.new(name, model)
end
model() click to toggle source
# File lib/singular_resource/strategy.rb, line 22
def model
  @model ||= case options[:model]
             when Class, Module
               options[:model]
             else
               name_or_model = options[:model] || name
               SingularResource::Inflector.class_for(name_or_model)
             end
end
params() click to toggle source
# File lib/singular_resource/strategy.rb, line 32
def params
  controller.params
end
request() click to toggle source
# File lib/singular_resource/strategy.rb, line 36
def request
  controller.request
end