lib/micro/case.rb in u-case-3.0.0.rc9 vs lib/micro/case.rb in u-case-3.0.0

- old
+ new

@@ -6,12 +6,12 @@ require 'micro/case/version' module Micro class Case require 'micro/case/utils' - require 'micro/case/result' require 'micro/case/error' + require 'micro/case/result' require 'micro/case/safe' require 'micro/case/strict' require 'micro/case/config' require 'micro/cases' @@ -20,15 +20,18 @@ def self.call(options = Kind::Empty::HASH) new(options).__call__ end + INVALID_INVOCATION_OF_THE_THE_METHOD = + Error::InvalidInvocationOfTheThenMethod.new(self.name) + def self.then(use_case = nil, &block) can_yield_self = respond_to?(:yield_self) if block - raise Error::InvalidInvocationOfTheThenMethod if use_case + raise INVALID_INVOCATION_OF_THE_THE_METHOD if use_case raise NotImplementedError if !can_yield_self yield_self(&block) else return yield_self if !use_case && can_yield_self @@ -68,11 +71,11 @@ "Related issue: https://github.com/serradura/u-case/issues/19\n" end end def self.__new__(result, arg) - input = result.__set_transitions_accessible_attributes__(arg) + input = result.__set_accessible_attributes__(arg) new(input).__set_result__(result) end def self.__flow_builder__ @@ -123,11 +126,11 @@ def call! raise NotImplementedError end def __call__ - __call! + call end def __set_result__(result) raise Error::InvalidResultInstance unless result.is_a?(Result) raise Error::ResultIsAlreadyDefined if defined?(@__result) @@ -137,25 +140,21 @@ self end private - # This method was reserved for a new feature def call + return __call_use_case_flow if __call_use_case_flow? + + __call_use_case end def __setup_use_case(input) self.class.__flow_set__! @__input = input self.attributes = input - end - - def __call! - return __call_use_case_flow if __call_use_case_flow? - - __call_use_case end def __call_use_case result = call!