Class: J8::Function
Class Method Summary
collapse
Instance Method Summary
collapse
Methods included from Common
callable_from_proc, from_callable, from_callable_class, initialize, lambda?, make_lambda, raise_unless_lambda
Class Method Details
23
24
25
|
# File 'lib/j8/function.rb', line 23
def self.identity
J8::Function.new { |o| o }
end
|
Instance Method Details
7
8
9
|
# File 'lib/j8/function.rb', line 7
def apply(o)
@callable.call(o)
end
|
#compose(before = nil, &block) ⇒ Object
11
12
13
14
15
|
# File 'lib/j8/function.rb', line 11
def compose(before = nil, &block)
callable = from_callable(before, block)
J8::Function.new(->(o) { apply(callable.apply(o)) })
end
|
#then(after = nil, &block) ⇒ Object
17
18
19
20
21
|
# File 'lib/j8/function.rb', line 17
def then(after = nil, &block)
callable = from_callable(after, block)
J8::Function.new(->(o) { callable.apply(apply(o)) })
end
|