Module: Kind::Function
- Defined in:
- lib/kind/function.rb
Class Method Summary collapse
Instance Method Summary collapse
Class Method Details
.extended(base) ⇒ Object
19 20 21 |
# File 'lib/kind/function.rb', line 19 def self.extended(base) base.extend(Kind.of_module(base)) end |
.included(_) ⇒ Object
15 16 17 |
# File 'lib/kind/function.rb', line 15 def self.included(_) raise RuntimeError, "The Kind::Function can't be included, it can be only extended." end |
Instance Method Details
#kind_function! ⇒ Object
23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 |
# File 'lib/kind/function.rb', line 23 def kind_function! return self if Kind.is?(Behavior, self) KIND.respond_to!(:call, self).extend(Behavior) if method(:call).parameters.empty? raise ArgumentError, "#{self.name}.call must receive at least one argument" end self.instance_eval( 'def to_proc; @to_proc ||= method(:call).to_proc; end' \ "\n" \ 'def curry; @curry ||= to_proc.curry; end' ) self.to_proc self.curry self end |