Class: Spine::Actions::Action

Inherits:
Object
  • Object
show all
Extended by:
Filters
Includes:
Formats, Parameters, Responder
Defined in:
lib/spine/actions/action.rb

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Methods included from Filters

after, after_filters, after_filters_with_parents, before, before_filters, before_filters_with_parents, process_filters

Methods included from Parameters

#params

Methods included from Formats

#format

Methods included from Responder

#build_url, #finish_response, #redirect, #respond, #responded?, #send_data

Constructor Details

#initialize(env) ⇒ Action

Returns a new instance of Action.



11
12
13
14
15
# File 'lib/spine/actions/action.rb', line 11

def initialize(env)
  @env = env
  @request = Rack::Request.new(env)
  @response = Rack::Response.new
end

Instance Attribute Details

#envObject (readonly)

Returns the value of attribute env.



9
10
11
# File 'lib/spine/actions/action.rb', line 9

def env
  @env
end

#requestObject (readonly)

Returns the value of attribute request.



9
10
11
# File 'lib/spine/actions/action.rb', line 9

def request
  @request
end

#responseObject (readonly)

Returns the value of attribute response.



9
10
11
# File 'lib/spine/actions/action.rb', line 9

def response
  @response
end

Class Method Details

.call(env) ⇒ Object

Raises:

  • (StandardError)


17
18
19
20
21
22
23
24
25
26
27
28
# File 'lib/spine/actions/action.rb', line 17

def self.call(env)
  handler = new(env)

  process_filters(handler, before_filters_with_parents)
  return handler.response.finish if handler.responded?

  handler.action
  process_filters(handler, after_filters_with_parents)

  raise StandardError.new('No response defined') unless handler.responded?
  handler.response.finish
end