Sha256: 98e95b6b389f8533c8613573875d7f1bd853a47bab3a88bb2b8cc59230fc598a

Contents?: true

Size: 1.01 KB

Versions: 8

Compression:

Stored size: 1.01 KB

Contents

require 'hanami/utils/class_attribute'

module Hanami
  module Action
    # Configuration API
    #
    # @since 0.2.0
    #
    # @see Hanami::Controller::Configuration
    module Configurable
      # Override Ruby's hook for modules.
      # It includes configuration logic
      #
      # @param base [Class] the target action
      #
      # @since 0.2.0
      # @api private
      #
      # @see http://www.ruby-doc.org/core-2.1.2/Module.html#method-i-included
      #
      # @example
      #   require 'hanami/controller'
      #
      #   class Show
      #     include Hanami::Action
      #   end
      #
      #   Show.configuration
      def self.included(base)
        config = Hanami::Controller::Configuration.for(base)

        base.class_eval do
          include Utils::ClassAttribute

          class_attribute :configuration
          self.configuration = config
        end

        config.copy!(base)
      end

      private

      def configuration
        self.class.configuration
      end
    end
  end
end

Version data entries

8 entries across 8 versions & 1 rubygems

Version Path
hanami-controller-1.0.0.beta2 lib/hanami/action/configurable.rb
hanami-controller-1.0.0.beta1 lib/hanami/action/configurable.rb
hanami-controller-0.8.1 lib/hanami/action/configurable.rb
hanami-controller-0.8.0 lib/hanami/action/configurable.rb
hanami-controller-0.7.1 lib/hanami/action/configurable.rb
hanami-controller-0.7.0 lib/hanami/action/configurable.rb
hanami-controller-0.6.1 lib/hanami/action/configurable.rb
hanami-controller-0.6.0 lib/hanami/action/configurable.rb