Module: Conduit::Core::Action::InstanceMethods

Defined in:
lib/conduit/core/action.rb

Instance Method Summary collapse

Instance Method Details

#initialize(**options) ⇒ Object



78
79
80
81
# File 'lib/conduit/core/action.rb', line 78

def initialize(**options)
  @options = options
  validate!(options)
end

#performObject

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

#viewObject

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_contextObject

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(@options.select do |k,v|
    attributes.include?(k)
  end)
end

#view_pathObject

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