Module: Conduit::Core::Action::InstanceMethods
- 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
78 79 80 81 |
# File 'lib/conduit/core/action.rb', line 78 def initialize(**) = validate!() end |
#perform ⇒ Object
Entry method. The class will use use this to trigger the request.
Override to customize.
114 115 116 |
# File 'lib/conduit/core/action.rb', line 114 def perform request(body: view, method: :post) end |
#view ⇒ Object
Return the rendered view
103 104 105 106 107 |
# File 'lib/conduit/core/action.rb', line 103 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.
87 88 89 90 91 |
# File 'lib/conduit/core/action.rb', line 87 def view_context OpenStruct.new(.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.
97 98 99 |
# File 'lib/conduit/core/action.rb', line 97 def view_path File.join(File.dirname(action_path), 'views') end |