Module: Invokable

Extended by:
Helpers
Defined in:
lib/invokable.rb,
lib/invokable/core.rb,
lib/invokable/closure.rb,
lib/invokable/command.rb,
lib/invokable/compose.rb,
lib/invokable/helpers.rb,
lib/invokable/version.rb

Overview

A module that attempts to generalize the notion of a first class function or Procs as they are often called in Ruby. It enables any class and it’s objects to be treated as first-class functions. It also provides helpers includes helpers that can be used for performing higher-order operations on and object that can be treated as a function.

Examples:

class TwitterPoster
  include Invokable

  def initialize(model)
    @model = model
  end

  def call(user)
    # do the dirt
    ...
    TwitterStatus.new(user, data)
  end
end

TwitterPoster.call(Model.find(1)) # => #<TwitterPoster ...>
TwitterPoster.call(Model.find(1), current_user) # => #<TwitterStatus ...>

Defined Under Namespace

Modules: ClassMethods, Closure, Command, Compose, Core, Helpers

Constant Summary collapse

VERSION =
"1.0.0"

Class Method Summary collapse

Methods included from Helpers

always, coerce, compose, guarded, identity, juxtapose, knit, partial

Class Method Details

.included(base) ⇒ Object



33
34
35
36
37
38
39
# File 'lib/invokable.rb', line 33

def self.included(base)
  INCLUDED_MODULES.each do |mod|
    base.include(mod)
    base.extend(mod)
  end
  base.extend(ClassMethods)
end