Sha256: 565708946e206dce58becdfcb1cfb5ddb4bfd2d75eb5c042712aaa431d207821

Contents?: true

Size: 1008 Bytes

Versions: 12

Compression:

Stored size: 1008 Bytes

Contents

# frozen_string_literal: true

module LunaPark
  module Extensions
    ##
    # class-level mixin
    #
    # The Callable interface is a generic interface
    # containing a single `call()` method - which returns
    # a generic value
    #
    # @example
    #  class MyCallableObject < LunaPark::Extensions::Callable
    #    def initialize(params)
    #      @params = params
    #    end
    #
    #    def call
    #      # do some stuff with @params
    #      'call used'
    #    end
    #
    #    def call!
    #      # do some stuff with @params
    #      'call! used'
    #    end
    #  end
    #
    #  MyCallableObject.call(params)  # => 'call used'
    #  MyCallableObject.call!(params) # => 'call! used'
    module Callable
      # Preferred class method to run instance `call` method
      def call(*args)
        new(*args).call
      end

      ##
      # Preferred class method to run instance `call`! method
      def call!(*args)
        new(*args).call!
      end
    end
  end
end

Version data entries

12 entries across 12 versions & 1 rubygems

Version Path
luna_park-0.13.1 lib/luna_park/extensions/callable.rb
luna_park-0.13.0 lib/luna_park/extensions/callable.rb
luna_park-0.12.1 lib/luna_park/extensions/callable.rb
luna_park-0.12.0 lib/luna_park/extensions/callable.rb
luna_park-0.11.7 lib/luna_park/extensions/callable.rb
luna_park-0.11.6 lib/luna_park/extensions/callable.rb
luna_park-0.11.5 lib/luna_park/extensions/callable.rb
luna_park-0.11.4 lib/luna_park/extensions/callable.rb
luna_park-0.11.3 lib/luna_park/extensions/callable.rb
luna_park-0.11.2 lib/luna_park/extensions/callable.rb
luna_park-0.11.1 lib/luna_park/extensions/callable.rb
luna_park-0.11.0 lib/luna_park/extensions/callable.rb