Class: Yogo::Operation

Inherits:
Proc
  • Object
show all
Defined in:
lib/yogo/operation.rb

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from Proc

#partial

Class Method Details

.on(type, &block) ⇒ Object



9
10
11
12
13
# File 'lib/yogo/operation.rb', line 9

def self.on(type, &block)
  op = self.new(&block)
  op.instance_eval{ self.type = type }
  op
end

Instance Method Details

#call(*args) ⇒ Object



15
16
17
18
19
# File 'lib/yogo/operation.rb', line 15

def call(*args)
  x = args.first
  raise "Can only invoke on #{type}" if type && !x.is_a?(type)
  super(*args)
end