Class: Command::ArgumentDecorator

Inherits:
Argument
  • Object
show all
Defined in:
lib/command-set/arguments.rb

Direct Known Subclasses

AlternatingArgument, Named, Optional, Repeating

Instance Attribute Summary

Attributes inherited from Argument

#name, #value

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from Argument

#check_present, #complete, #consume, #consume_hash, #match_terms, #omittable?, #parse, #required?, #validate

Constructor Details

#initialize(up) ⇒ ArgumentDecorator

Returns a new instance of ArgumentDecorator.



107
108
109
# File 'lib/command-set/arguments.rb', line 107

def initialize(up)
  @wrapping_decorator = up
end

Class Method Details

.decorObject



99
100
101
# File 'lib/command-set/arguments.rb', line 99

def self.decor
  @decor
end

.decoration(&block) ⇒ Object



95
96
97
# File 'lib/command-set/arguments.rb', line 95

def self.decoration(&block)
  @decor = block
end

.register(name) ⇒ Object Also known as: register_as



87
88
89
# File 'lib/command-set/arguments.rb', line 87

def self.register(name)
  DSL::Argument::register_decorator(self, name)
end

Instance Method Details

#decorObject



103
104
105
# File 'lib/command-set/arguments.rb', line 103

def decor
  self.class.decor
end

#decorate(argument) ⇒ Object



115
116
117
118
119
# File 'lib/command-set/arguments.rb', line 115

def decorate(argument)
  block = decor
  (class << argument; self; end).class_eval &block
  return argument
end

#embed_argument(argument) ⇒ Object



111
112
113
# File 'lib/command-set/arguments.rb', line 111

def embed_argument(argument)
  @wrapping_decorator.embed_argument(decorate(argument))
end