Sha256: ebaf7f37acfe34cee58d7a94d38dab0e4a25fc27906f8470aa5e89cf79b29e73

Contents?: true

Size: 1.28 KB

Versions: 3

Compression:

Stored size: 1.28 KB

Contents

module Plutonium
  module Reactor
    class ResourcePresenter
      include Plutonium::Core::Definers::FieldDefiner
      include Plutonium::Core::Definers::ActionDefiner

      def initialize(context, resource_record)
        @context = context
        @resource_record = resource_record

        define_standard_actions
        define_actions
        define_fields
      end

      def search_field
        nil
      end

      private

      attr_reader :context, :resource_record

      def define_fields
        # override this in child presenters for custom field definitions
      end

      def define_actions
        # override this in child presenters for custom action definitions
      end

      def define_standard_actions
        define_action Plutonium::Core::Actions::NewAction.new(:new)
        define_action Plutonium::Core::Actions::ShowAction.new(:show)
        define_action Plutonium::Core::Actions::EditAction.new(:edit)
        define_action Plutonium::Core::Actions::DestroyAction.new(:destroy)
      end

      # TODO: move this to its own definer
      def define_interactive_action(name, interaction:, **)
        define_action Plutonium::Core::Actions::InteractiveAction.new(name, interaction:, **)
      end

      def resource_class = context.resource_class
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
plutonium-0.6.2 lib/plutonium/reactor/resource_presenter.rb
plutonium-0.6.1 lib/plutonium/reactor/resource_presenter.rb
plutonium-0.6.0 lib/plutonium/reactor/resource_presenter.rb