Class: ConvenientService::Service::Plugins::CanHaveConnectedSteps::Entities::Expressions::ComplexIf Private

Inherits:
Base
  • Object
show all
Defined in:
lib/convenient_service/service/plugins/can_have_connected_steps/entities/expressions/complex_if.rb

Overview

This class is part of a private API. You should avoid using this class if possible, as it may be removed or be changed in the future.

Since:

  • 1.0.0

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods inherited from Base

#and?, #else?, #empty?, #group?, #if?, #not?, #or?, #scalar?, #steps

Methods included from ConvenientService::Support::Copyable

#copy

Methods included from ConvenientService::Support::AbstractMethod

abstract_method

Methods included from ConvenientService::Support::Concern

included

Constructor Details

#initialize(if_expression, elsif_expressions, else_expression) ⇒ void

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.



39
40
41
42
43
# File 'lib/convenient_service/service/plugins/can_have_connected_steps/entities/expressions/complex_if.rb', line 39

def initialize(if_expression, elsif_expressions, else_expression)
  @if_expression = if_expression
  @elsif_expressions = elsif_expressions
  @else_expression = else_expression
end

Instance Attribute Details

#else_expressionObject (readonly)

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Since:

  • 1.0.0



31
32
33
# File 'lib/convenient_service/service/plugins/can_have_connected_steps/entities/expressions/complex_if.rb', line 31

def else_expression
  @else_expression
end

#elsif_expressionsObject (readonly)

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Since:

  • 1.0.0



25
26
27
# File 'lib/convenient_service/service/plugins/can_have_connected_steps/entities/expressions/complex_if.rb', line 25

def elsif_expressions
  @elsif_expressions
end

#if_expressionObject (readonly)

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Since:

  • 1.0.0



19
20
21
# File 'lib/convenient_service/service/plugins/can_have_connected_steps/entities/expressions/complex_if.rb', line 19

def if_expression
  @if_expression
end

Instance Method Details

#==(other) ⇒ Boolean?

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Parameters:

  • other (Object)

    Can be any type.

Returns:

  • (Boolean, nil)

Since:

  • 1.0.0



198
199
200
201
202
203
204
205
206
# File 'lib/convenient_service/service/plugins/can_have_connected_steps/entities/expressions/complex_if.rb', line 198

def ==(other)
  return unless other.instance_of?(self.class)

  return false if if_expression != other.if_expression
  return false if elsif_expressions != other.elsif_expressions
  return false if else_expression != other.else_expression

  true
end

#complex_if?Boolean

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Returns:

  • (Boolean)

Since:

  • 1.0.0



190
191
192
# File 'lib/convenient_service/service/plugins/can_have_connected_steps/entities/expressions/complex_if.rb', line 190

def complex_if?
  true
end

#each_evaluated_step(&block) ⇒ ConvenientService::Service::Plugins::CanHaveConnectedSteps::Entities::Expressions::Base

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

rubocop:disable Lint/NonLocalExitFromIterator



133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
# File 'lib/convenient_service/service/plugins/can_have_connected_steps/entities/expressions/complex_if.rb', line 133

def each_evaluated_step(&block)
  if_expression.condition_expression.each_evaluated_step(&block)

  return if if_expression.condition_expression.error?
  return if_expression.then_expression.each_evaluated_step(&block) if if_expression.condition_expression.success?

  elsif_expressions.each do |elsif_expression|
    elsif_expression.condition_expression.each_evaluated_step(&block)

    return if elsif_expression.condition_expression.error?
    return elsif_expression.then_expression.each_evaluated_step(&block) if elsif_expression.condition_expression.success?
  end

  else_expression&.each_evaluated_step(&block)

  self
end

#each_step(&block) ⇒ ConvenientService::Service::Plugins::CanHaveConnectedSteps::Entities::Expressions::Base

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.



116
117
118
119
120
121
122
123
124
125
126
# File 'lib/convenient_service/service/plugins/can_have_connected_steps/entities/expressions/complex_if.rb', line 116

def each_step(&block)
  if_expression.each_step(&block)

  elsif_expressions.each do |elsif_expression|
    elsif_expression.each_step(&block)
  end

  else_expression&.each_step(&block)

  self
end

#error?Boolean

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Returns:

  • (Boolean)

Since:

  • 1.0.0



100
101
102
103
104
105
106
107
108
109
110
# File 'lib/convenient_service/service/plugins/can_have_connected_steps/entities/expressions/complex_if.rb', line 100

def error?
  return true if if_expression.condition_expression.error?
  return if_expression.then_expression.error? if if_expression.condition_expression.success?

  elsif_expressions.each do |elsif_expression|
    return true if elsif_expression.condition_expression.error?
    return elsif_expression.then_expression.error? if elsif_expression.condition_expression.success?
  end

  else_expression ? else_expression.error? : false
end

#failure?Boolean

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Returns:

  • (Boolean)

Since:

  • 1.0.0



85
86
87
88
89
90
91
92
93
94
95
# File 'lib/convenient_service/service/plugins/can_have_connected_steps/entities/expressions/complex_if.rb', line 85

def failure?
  return false if if_expression.condition_expression.error?
  return if_expression.then_expression.failure? if if_expression.condition_expression.success?

  elsif_expressions.each do |elsif_expression|
    return false if elsif_expression.condition_expression.error?
    return elsif_expression.then_expression.failure? if elsif_expression.condition_expression.success?
  end

  else_expression ? else_expression.failure? : false
end

#inspectString

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Returns:

  • (String)

Since:

  • 1.0.0



171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
# File 'lib/convenient_service/service/plugins/can_have_connected_steps/entities/expressions/complex_if.rb', line 171

def inspect
  parts = [
    "if #{if_expression.condition_expression.inspect} then #{if_expression.then_expression.inspect}"
  ]

  elsif_expressions.each do |elsif_expression|
    parts << "elsif #{elsif_expression.condition_expression.inspect} then #{elsif_expression.then_expression.inspect}"
  end

  parts << "else #{else_expression.expression.inspect}" if else_expression

  parts << "end"

  parts.join(" ")
end

#organizerConvenientService::Service

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Returns:

Since:

  • 1.0.0



63
64
65
# File 'lib/convenient_service/service/plugins/can_have_connected_steps/entities/expressions/complex_if.rb', line 63

def organizer
  if_expression.organizer
end

#resultConvenientService::Service::Plugins::HasJSendResult::Entities::Result

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.



48
49
50
51
52
53
54
55
56
57
58
# File 'lib/convenient_service/service/plugins/can_have_connected_steps/entities/expressions/complex_if.rb', line 48

def result
  return if_expression.condition_expression.result if if_expression.condition_expression.error?
  return if_expression.then_expression.result if if_expression.condition_expression.success?

  elsif_expressions.each do |elsif_expression|
    return elsif_expression.condition_expression.result if elsif_expression.condition_expression.error?
    return elsif_expression.then_expression.result if elsif_expression.condition_expression.success?
  end

  else_expression ? else_expression.result : organizer.success
end

#success?Boolean

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Returns:

  • (Boolean)

Since:

  • 1.0.0



70
71
72
73
74
75
76
77
78
79
80
# File 'lib/convenient_service/service/plugins/can_have_connected_steps/entities/expressions/complex_if.rb', line 70

def success?
  return false if if_expression.condition_expression.error?
  return if_expression.then_expression.success? if if_expression.condition_expression.success?

  elsif_expressions.each do |elsif_expression|
    return false if elsif_expression.condition_expression.error?
    return elsif_expression.then_expression.success? if elsif_expression.condition_expression.success?
  end

  else_expression ? else_expression.success? : true
end

#to_argumentsConvenientService::Support::Arguments

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Returns:

Since:

  • 1.0.0



211
212
213
# File 'lib/convenient_service/service/plugins/can_have_connected_steps/entities/expressions/complex_if.rb', line 211

def to_arguments
  Support::Arguments.new(if_expression, elsif_expressions, else_expression)
end

#with_organizer(organizer) ⇒ ConvenientService::Service::Plugins::CanHaveConnectedSteps::Entities::Expressions::Not

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.



156
157
158
159
160
161
162
163
164
165
166
# File 'lib/convenient_service/service/plugins/can_have_connected_steps/entities/expressions/complex_if.rb', line 156

def with_organizer(organizer)
  copy(
    overrides: {
      args: {
        0 => if_expression.with_organizer(organizer),
        1 => elsif_expressions.map { |elsif_expression| elsif_expression.with_organizer(organizer) },
        2 => else_expression&.with_organizer(organizer)
      }
    }
  )
end