Class: ConvenientService::Service::Plugins::CanHaveStepAwareEnumerables::Commands::CastStepAwareEnumerator
- Inherits:
-
ConvenientService::Support::Command
- Object
- ConvenientService::Support::Command
- ConvenientService::Service::Plugins::CanHaveStepAwareEnumerables::Commands::CastStepAwareEnumerator
- Defined in:
- lib/convenient_service/service/plugins/can_have_step_aware_enumerables/commands/cast_step_aware_enumerator.rb
Constant Summary collapse
- RUBY_CLASS_TO_STEP_AWARE_CLASS_MAP =
{ ::Enumerator => Entities::StepAwareEnumerables::Enumerator, ::Enumerator::Lazy => Entities::StepAwareEnumerables::LazyEnumerator, ::Enumerator::Chain => Entities::StepAwareEnumerables::ChainEnumerator, ::Enumerator::ArithmeticSequence => Entities::StepAwareEnumerables::ArithmeticSequenceEnumerator }
Instance Attribute Summary collapse
-
#object ⇒ Object
readonly
Returns the value of attribute object.
-
#organizer ⇒ Object
readonly
Returns the value of attribute organizer.
-
#propagated_result ⇒ Object
readonly
Returns the value of attribute propagated_result.
Instance Method Summary collapse
- #call ⇒ ConvenientService::Service::Plugins::CanHaveStepAwareEnumerables::Entities::StepAwareEnumerables::Base
- #fallback_step_aware_enumerator_klass ⇒ Class?
- #initialize(object:, organizer:, propagated_result: nil) ⇒ void constructor
- #step_aware_enumerator_klass ⇒ Class?
Methods inherited from ConvenientService::Support::Command
Constructor Details
#initialize(object:, organizer:, propagated_result: nil) ⇒ void
48 49 50 51 52 |
# File 'lib/convenient_service/service/plugins/can_have_step_aware_enumerables/commands/cast_step_aware_enumerator.rb', line 48 def initialize(object:, organizer:, propagated_result: nil) @object = object @organizer = organizer @propagated_result = propagated_result end |
Instance Attribute Details
#object ⇒ Object (readonly)
Returns the value of attribute object.
28 29 30 |
# File 'lib/convenient_service/service/plugins/can_have_step_aware_enumerables/commands/cast_step_aware_enumerator.rb', line 28 def object @object end |
#organizer ⇒ Object (readonly)
Returns the value of attribute organizer.
34 35 36 |
# File 'lib/convenient_service/service/plugins/can_have_step_aware_enumerables/commands/cast_step_aware_enumerator.rb', line 34 def organizer @organizer end |
#propagated_result ⇒ Object (readonly)
Returns the value of attribute propagated_result.
40 41 42 |
# File 'lib/convenient_service/service/plugins/can_have_step_aware_enumerables/commands/cast_step_aware_enumerator.rb', line 40 def propagated_result @propagated_result end |
Instance Method Details
#call ⇒ ConvenientService::Service::Plugins::CanHaveStepAwareEnumerables::Entities::StepAwareEnumerables::Base
58 59 60 61 62 63 |
# File 'lib/convenient_service/service/plugins/can_have_step_aware_enumerables/commands/cast_step_aware_enumerator.rb', line 58 def call return step_aware_enumerator_klass.new(object: object, organizer: organizer, propagated_result: propagated_result) if step_aware_enumerator_klass return fallback_step_aware_enumerator_klass.new(object: object, organizer: organizer, propagated_result: propagated_result) if fallback_step_aware_enumerator_klass raise ::ConvenientService.raise Exceptions::ObjectIsNotEnumerator.new(object: object) end |
#fallback_step_aware_enumerator_klass ⇒ Class?
75 76 77 |
# File 'lib/convenient_service/service/plugins/can_have_step_aware_enumerables/commands/cast_step_aware_enumerator.rb', line 75 def fallback_step_aware_enumerator_klass Utils.memoize_including_falsy_values(self, :@fallback_step_aware_enumerator_klass) { Entities::StepAwareEnumerables::Enumerator if object.respond_to?(:each) } end |
#step_aware_enumerator_klass ⇒ Class?
68 69 70 |
# File 'lib/convenient_service/service/plugins/can_have_step_aware_enumerables/commands/cast_step_aware_enumerator.rb', line 68 def step_aware_enumerator_klass Utils.memoize_including_falsy_values(self, :@step_aware_enumerator_klass) { RUBY_CLASS_TO_STEP_AWARE_CLASS_MAP[object.class] } end |