Module: Caliph::DefineOp::ClassMethods

Defined in:
lib/caliph/define-op.rb

Instance Method Summary collapse

Instance Method Details

#define_chain_op(opname, klass) ⇒ Object



8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
# File 'lib/caliph/define-op.rb', line 8

def define_chain_op(opname, klass)
  define_method(opname) do |other|
    unless CommandLine === other
      other = CommandLine.new(*[*other])
    end
    chain = nil
    if klass === self
      chain = self
    else
      chain = klass.new
      chain.add(self)
    end
    chain.add(other)
  end
end

#define_op(opname) ⇒ Object



24
25
26
# File 'lib/caliph/define-op.rb', line 24

def define_op(opname)
  CommandLine.define_chain_op(opname, self)
end