Module: Opinio::Controllers::InternalHelpers

Extended by:
ActiveSupport::Concern
Included in:
Opinio::CommentsController
Defined in:
lib/opinio/controllers/internal_helpers.rb

Instance Method Summary (collapse)

Instance Method Details

- (Object) custom_resource_identifier(params)



24
25
26
# File 'lib/opinio/controllers/internal_helpers.rb', line 24

def custom_resource_identifier(params)
  Opinio.check_custom_identifiers(params)
end

- (Object) resource



10
11
12
# File 'lib/opinio/controllers/internal_helpers.rb', line 10

def resource
  @resource ||= custom_resource_identifier(params) || resource_by_params 
end

- (Object) resource_by_params



14
15
16
17
18
19
20
21
22
# File 'lib/opinio/controllers/internal_helpers.rb', line 14

def resource_by_params
  if params[:commentable_type]
    params[:commentable_type].constantize.find(params[:commentable_id])
  elsif params[:comment]
    params[:comment][:commentable_type].constantize.find(params[:comment][:commentable_id])
  else
    raise "Unable to determine comments holder"
  end
end

- (Object) resource_name



28
29
30
# File 'lib/opinio/controllers/internal_helpers.rb', line 28

def resource_name
  Opinio.model_name
end

- (Object) set_flash(name, message)



32
33
34
# File 'lib/opinio/controllers/internal_helpers.rb', line 32

def set_flash(name, message)
  flash[name] = message if Opinio.set_flash
end