Class: Aldous::Controller::Action::Precondition

Inherits:
Object
  • Object
show all
Includes:
Aldous
Defined in:
lib/aldous/controller/action/precondition.rb,
lib/aldous/controller/action/precondition/wrapper.rb

Defined Under Namespace

Classes: Wrapper

Constant Summary

Constants included from Aldous

VERSION

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Methods included from Aldous

configuration

Constructor Details

#initialize(action, controller, view_builder) ⇒ Precondition

Returns a new instance of Precondition.



31
32
33
34
35
# File 'lib/aldous/controller/action/precondition.rb', line 31

def initialize(action, controller, view_builder)
  @action = action
  @controller = controller
  @view_builder = view_builder
end

Instance Attribute Details

#actionObject (readonly)

Returns the value of attribute action.



29
30
31
# File 'lib/aldous/controller/action/precondition.rb', line 29

def action
  @action
end

#controllerObject (readonly)

Returns the value of attribute controller.



29
30
31
# File 'lib/aldous/controller/action/precondition.rb', line 29

def controller
  @controller
end

#view_builderObject (readonly)

Returns the value of attribute view_builder.



29
30
31
# File 'lib/aldous/controller/action/precondition.rb', line 29

def view_builder
  @view_builder
end

Class Method Details

.build(action, controller, view_builder) ⇒ Object



10
11
12
# File 'lib/aldous/controller/action/precondition.rb', line 10

def build(action, controller, view_builder)
  Aldous::Controller::Action::Precondition::Wrapper.new(new(action, controller, view_builder))
end

.inherited(klass) ⇒ Object



18
19
20
21
22
23
24
25
26
# File 'lib/aldous/controller/action/precondition.rb', line 18

def inherited(klass)
  ::Aldous.configuration.controller_methods_exposed_to_action.each do |method_name|
    unless klass.method_defined?(method_name)
      define_method method_name do
        controller.send(method_name)
      end
    end
  end
end

.perform(action, controller, view_builder) ⇒ Object



14
15
16
# File 'lib/aldous/controller/action/precondition.rb', line 14

def perform(action, controller, view_builder)
  build(action, controller, view_builder).perform
end

Instance Method Details

#build_view(respondable_class, extra_data = {}) ⇒ Object

NOTE deprecated



44
45
46
# File 'lib/aldous/controller/action/precondition.rb', line 44

def build_view(respondable_class, extra_data = {}) # deprecated
  view_builder.build(respondable_class, extra_data)
end

#performObject

Raises:

  • (NotImplementedError)


37
38
39
# File 'lib/aldous/controller/action/precondition.rb', line 37

def perform
  raise NotImplementedError.new("#{self.class.name} must implement method #perform")
end