Sha256: 6da6c7bf9c28bc43dd0fc69bafa86b6ff7b69feebc85e783e080890dd2bd64a2

Contents?: true

Size: 896 Bytes

Versions: 1

Compression:

Stored size: 896 Bytes

Contents

require "clamp/attribute/declaration"
require "clamp/parameter/definition"

module Clamp
  module Parameter

    module Declaration

      include Clamp::Attribute::Declaration

      def parameters
        @parameters ||= []
      end

      def has_parameters?
        !parameters.empty?
      end

      def parameter(name, description, options = {}, &block)
        Parameter::Definition.new(name, description, options).tap do |parameter|
          declare_attribute(parameter, &block)
          parameters << parameter
        end
      end

      protected

      def inheritable_parameters
        superclass_inheritable_parameters + parameters.select(&:inheritable?)
      end

      private

      def superclass_inheritable_parameters
        return [] unless superclass.respond_to?(:inheritable_parameters, true)
        superclass.inheritable_parameters
      end

    end

  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
clamp-1.1.0 lib/clamp/parameter/declaration.rb