1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42
|
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|
define_accessors_for(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
|