lib/sinclair/method_definitions.rb in sinclair-1.10.0 vs lib/sinclair/method_definitions.rb in sinclair-1.11.0
- old
+ new
@@ -10,40 +10,38 @@
# Builds and adds new definition
#
# The type is decided based in the arguments
#
- # @param name [String,Symbol] method name
- # @param options [Hash] Options of construction
- # @option options cached [Boolean] Flag telling to create
- # a method with cache
- #
# @overload add(definition_class, name, code = nil, **options)
+ # @param name [String,Symbol] method name
# @param code [String] code to be evaluated when the method is ran
+ # @param options [Hash] Options of construction
+ # @option options cached [Boolean] Flag telling to create
+ # a method with cache
#
# @overload add(definition_class, name, **options, &block)
+ # @param name [String,Symbol] method name
+ # @param options [Hash] Options of construction
+ # @option options cached [Boolean] Flag telling to create
+ # a method with cache
# @param block [Proc] block to be ran as method
#
- # @return [Array<MethodDefinition>]
- def add(name, code = nil, **options, &block)
- definitions << MethodDefinition.from(name, code, **options, &block)
- end
-
- # Builds and adds new definition
+ # @overload add(type, *args, **options, &block)
+ # @param type [Symbol] type of definition
+ # - :string -> {MethodDefinition::StringDefinition}
+ # - :block -> {MethodDefinition::BlockDefinition}
+ # - :call -> {MethodDefinition::CallDefinition}
+ # @param options [Hash] Options of construction
+ # @option options cached [Boolean] Flag telling to create
+ # a method with cache
+ # @param block [Proc] block to be ran as method
#
- # The type is decided based on the argument +type+
+ # @see MethodDefinition.for
+ # @see MethodDefinition.from
#
- # @param type [Symbol] type of definition
- # - :string -> {MethodDefinition::StringDefinition}
- # - :block -> {MethodDefinition::BlockDefinition}
- # - :call -> {MethodDefinition::CallDefinition}
- # @param options [Hash] Options of construction
- # @option options cached [Boolean] Flag telling to create
- # a method with cache
- # @param block [Proc] block to be ran as method
- #
# @return [Array<MethodDefinition>]
- def add_definition(type, *args, **options, &block)
+ def add(*args, type: nil, **options, &block)
definitions << MethodDefinition.for(type, *args, **options, &block)
end
private