lib/procto.rb in procto-0.0.1 vs lib/procto.rb in procto-0.0.2
- old
+ new
@@ -4,11 +4,11 @@
# The default name of the instance method to be called
DEFAULT_NAME = :call
private_class_method :new
- # Return a custom module that calls a method named +name+
+ # Return a module that turns the host into a method object
#
# @example without a name
#
# class Greeter
# include Procto.call
@@ -38,31 +38,29 @@
# end
# end
#
# Printer.call('world') # => "Hello world"
#
- # @param [Symbol, String] name
+ # @param [#to_sym] name
# the name of the instance method to call
#
# @return [Procto]
#
# @api public
def self.call(name = DEFAULT_NAME)
- new(name)
+ new(name.to_sym)
end
# Initialize a new instance
#
- # @param [Symbol, String] name
+ # @param [Symbol] name
# the name of the instance method to call
#
# @return [undefined]
#
# @api private
def initialize(name)
- @block = ->(*args) {
- new(*args).public_send(name)
- }
+ @block = ->(*args) { new(*args).public_send(name) }
end
private
# Define the .call method on +host+