lib/clamp/parameter/definition.rb in clamp-1.0.1 vs lib/clamp/parameter/definition.rb in clamp-1.1.0

- old
+ new

@@ -1,6 +1,6 @@ -require 'clamp/attribute/definition' +require "clamp/attribute/definition" module Clamp module Parameter class Definition < Attribute::Definition @@ -11,14 +11,19 @@ super(options) @multivalued = (@name =~ ELLIPSIS_SUFFIX) @required = options.fetch(:required) do (@name !~ OPTIONAL) end + @inheritable = options.fetch(:inheritable, true) end attr_reader :name + def inheritable? + @inheritable + end + def help_lhs name end def consume(arguments) @@ -32,10 +37,10 @@ OPTIONAL = /^\[(.*)\]/ VALID_ATTRIBUTE_NAME = /^[a-z0-9_]+$/ def infer_attribute_name - inferred_name = name.downcase.tr('-', '_').sub(ELLIPSIS_SUFFIX, '').sub(OPTIONAL) { $1 } + inferred_name = name.downcase.tr("-", "_").sub(ELLIPSIS_SUFFIX, "").sub(OPTIONAL) { Regexp.last_match(1) } unless inferred_name =~ VALID_ATTRIBUTE_NAME raise "cannot infer attribute_name from #{name.inspect}" end inferred_name += "_list" if multivalued? inferred_name