Class: Proc

Inherits:
Object
  • Object
show all
Defined in:
lib/lab42/stream/proc.rb

Instance Method Summary collapse

Instance Method Details

#make_behavior(*args) ⇒ Object

TODO: Use this from core/fn as soon as available

Raises:

  • (ArgumentError)


16
17
18
19
# File 'lib/lab42/stream/proc.rb', line 16

def make_behavior *args
  raise ArgumentError, "cannot specify behavior with block and args: #{args.inspect}" unless args.compact.empty?
  self
end

#memoizedObject



2
3
4
5
6
7
8
9
10
11
12
13
# File 'lib/lab42/stream/proc.rb', line 2

def memoized
  already_run = false
  result      = nil
  ->{
    if already_run
      result
    else
      already_run = true
      result = call()
    end
  }
end

#notObject



21
22
23
24
25
# File 'lib/lab42/stream/proc.rb', line 21

def not
  -> (*args, &blk) {
    ! self.(*args, &blk)
  }
end