Sha256: e400e16d2e12972d1bd5ae71cae7e35a2216016b75f38f02e2a36f073e9fcdcd

Contents?: true

Size: 1.47 KB

Versions: 2

Compression:

Stored size: 1.47 KB

Contents

require 'aldous/controller/action/precondition/wrapper'

module Aldous
  module Controller
    module Action
      class Precondition
        include Aldous

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

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

          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
        end

        attr_reader :action, :controller, :view_builder

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

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

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

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
aldous-1.1.3 lib/aldous/controller/action/precondition.rb
aldous-1.1.2 lib/aldous/controller/action/precondition.rb