Module: Conduit::Core::Action::InstanceMethods
- Extended by:
- Forwardable
- Defined in:
- lib/conduit/core/action.rb
Instance Method Summary collapse
- #initialize(**options) ⇒ Object
-
#perform ⇒ Object
Entry method.
-
#view ⇒ Object
Return the rendered view.
-
#view_context ⇒ Object
Object used for passing data to the view Only keys listed in attributes will be used.
-
#view_path ⇒ Object
Location where the view files can be found Default to lib/conduit/drivers/<drivername>/views Can be overriden per class.
Instance Method Details
#initialize(**options) ⇒ Object
80 81 82 83 |
# File 'lib/conduit/core/action.rb', line 80 def initialize(**) @options = validate!() end |
#perform ⇒ Object
Entry method. The class will use use this to trigger the request.
Override to customize.
127 128 129 130 131 132 133 |
# File 'lib/conduit/core/action.rb', line 127 def perform response = request(body: view, method: :post) parser = parser_class.new(response.body) Conduit::ApiResponse.new(raw_response: response, parser: parser) end |
#view ⇒ Object
Return the rendered view
116 117 118 119 120 |
# File 'lib/conduit/core/action.rb', line 116 def view tpl = self.class.name.demodulize .underscore.downcase render(tpl) end |
#view_context ⇒ Object
Object used for passing data to the view Only keys listed in attributes will be used.
100 101 102 103 104 |
# File 'lib/conduit/core/action.rb', line 100 def view_context OpenStruct.new(@options.select do |k, v| attributes.include?(k) end) end |
#view_path ⇒ Object
Location where the view files can be found Default to lib/conduit/drivers/<drivername>/views Can be overriden per class.
110 111 112 |
# File 'lib/conduit/core/action.rb', line 110 def view_path File.join(File.dirname(action_path), 'views') end |