lib/hanami/interactor.rb in hanami-utils-0.7.2 vs lib/hanami/interactor.rb in hanami-utils-0.8.0

- old
+ new

@@ -15,11 +15,11 @@ # # @since 0.3.5 # @api private # # @see Hanami::Interactor::Result#respond_to_missing? - METHODS = {initialize: true, success?: true, fail!: true, prepare!: true, errors: true, error: true}.freeze + METHODS = ::Hash[initialize: true, success?: true, fail!: true, prepare!: true, errors: true, error: true].freeze # Initialize a new result # # @param payload [Hash] a payload to carry on # @@ -95,19 +95,20 @@ @payload.merge!(_payload(payload)) self end protected + # @since 0.3.5 # @api private def method_missing(m, *) @payload.fetch(m) { super } end # @since 0.3.5 # @api private - def respond_to_missing?(method_name, include_all) + def respond_to_missing?(method_name, _include_all) method_name = method_name.to_sym METHODS[method_name] || @payload.key?(method_name) end # @since 0.3.5 @@ -117,11 +118,11 @@ end # @since 0.3.5 # @api private def __inspect - " @success=#{ @success } @payload=#{ @payload.inspect }" + " @success=#{@success} @payload=#{@payload.inspect}" end end # Override for <tt>Module#included</tt>. # @@ -249,10 +250,11 @@ _call { super } end end private + # Check if proceed with <tt>#call</tt> invokation. # By default it returns <tt>true</tt>. # # Developers can override it. # @@ -457,11 +459,11 @@ class_attribute :exposures self.exposures = Utils::Hash.new end end - # Expose local instance variables into the returing value of <tt>#call</tt> + # Expose local instance variables into the returning value of <tt>#call</tt> # # @param instance_variable_names [Symbol,Array<Symbol>] one or more instance # variable names # # @since 0.5.0 @@ -488,10 +490,10 @@ # # result.user # => #<User:0x007fa85c58ccd8 @name="Luca"> # result.params # => NoMethodError def expose(*instance_variable_names) instance_variable_names.each do |name| - exposures[name] = "@#{ name }" + exposures[name] = "@#{name}" end end end end