Class: K8::BaseAction

Inherits:
Object
  • Object
show all
Defined in:
lib/keight.rb

Overview

Equivarent to BaseController or AbstractRequestHandler in other framework.

Direct Known Subclasses

Action

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(req, resp) ⇒ BaseAction

Returns a new instance of BaseAction.



678
679
680
681
682
# File 'lib/keight.rb', line 678

def initialize(req, resp)
  #; [!uotpb] accepts request and response objects.
  @req  = req
  @resp = resp
end

Instance Attribute Details

#reqObject (readonly)

Returns the value of attribute req.



684
685
686
# File 'lib/keight.rb', line 684

def req
  @req
end

#respObject (readonly)

Returns the value of attribute resp.



684
685
686
# File 'lib/keight.rb', line 684

def resp
  @resp
end

#sessObject (readonly)

Returns the value of attribute sess.



684
685
686
# File 'lib/keight.rb', line 684

def sess
  @sess
end

Instance Method Details

#handle_action(action_name, urlpath_args) ⇒ Object



686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
# File 'lib/keight.rb', line 686

def handle_action(action_name, urlpath_args)
  @action_name = action_name
  @action_args = urlpath_args
  ex = nil
  begin
    #; [!5jnx6] calls '#before_action()' before handling request.
    before_action()
    #; [!ddgx3] invokes action method with urlpath params.
    content = invoke_action(action_name, urlpath_args)
    #; [!aqa4e] returns content.
    return handle_content(content)
  rescue Exception => ex
    raise
  ensure
    #; [!67awf] calls '#after_action()' after handling request.
    #; [!alpka] calls '#after_action()' even when error raised.
    after_action(ex)
  end
end