Class: ConvenientService::Service::Plugins::CanHaveConnectedSteps::Entities::Expressions::Or

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

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods inherited from Base

#and?, #empty?, #group?, #not?, #scalar?, #steps

Methods included from ConvenientService::Support::Copyable

#copy

Methods included from ConvenientService::Support::Concern

included

Constructor Details

#initialize(left_expression, right_expression) ⇒ void

Parameters:



27
28
29
30
# File 'lib/convenient_service/service/plugins/can_have_connected_steps/entities/expressions/or.rb', line 27

def initialize(left_expression, right_expression)
  @left_expression = left_expression
  @right_expression = right_expression
end

Instance Attribute Details

#left_expressionObject (readonly)

Returns the value of attribute left_expression.



14
15
16
# File 'lib/convenient_service/service/plugins/can_have_connected_steps/entities/expressions/or.rb', line 14

def left_expression
  @left_expression
end

#right_expressionObject (readonly)

Returns the value of attribute right_expression.



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

def right_expression
  @right_expression
end

Instance Method Details

#==(other) ⇒ Boolean

Parameters:

  • other (Object)

    Can be any type.

Returns:

  • (Boolean)


130
131
132
133
134
135
136
137
# File 'lib/convenient_service/service/plugins/can_have_connected_steps/entities/expressions/or.rb', line 130

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

  return false if left_expression != other.left_expression
  return false if right_expression != other.right_expression

  true
end

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



93
94
95
96
97
98
99
100
101
102
# File 'lib/convenient_service/service/plugins/can_have_connected_steps/entities/expressions/or.rb', line 93

def each_evaluated_step(&block)
  left_expression.each_evaluated_step(&block)

  return self if left_expression.success?
  return self if left_expression.error?

  right_expression.each_evaluated_step(&block)

  self
end

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



82
83
84
85
86
87
# File 'lib/convenient_service/service/plugins/can_have_connected_steps/entities/expressions/or.rb', line 82

def each_step(&block)
  left_expression.each_step(&block)
  right_expression.each_step(&block)

  self
end

#error?Boolean

Returns:

  • (Boolean)


71
72
73
74
75
76
# File 'lib/convenient_service/service/plugins/can_have_connected_steps/entities/expressions/or.rb', line 71

def error?
  return false if left_expression.success?
  return true if left_expression.error?

  right_expression.error?
end

#failure?Boolean

Returns:

  • (Boolean)


61
62
63
64
65
66
# File 'lib/convenient_service/service/plugins/can_have_connected_steps/entities/expressions/or.rb', line 61

def failure?
  return false if left_expression.success?
  return false if left_expression.error?

  right_expression.failure?
end

#inspectString

Returns:

  • (String)


115
116
117
# File 'lib/convenient_service/service/plugins/can_have_connected_steps/entities/expressions/or.rb', line 115

def inspect
  "#{left_expression.inspect} || #{right_expression.inspect}"
end

#or?Boolean

Returns:

  • (Boolean)


122
123
124
# File 'lib/convenient_service/service/plugins/can_have_connected_steps/entities/expressions/or.rb', line 122

def or?
  true
end

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



35
36
37
38
39
40
# File 'lib/convenient_service/service/plugins/can_have_connected_steps/entities/expressions/or.rb', line 35

def result
  return left_expression.result if left_expression.success?
  return left_expression.result if left_expression.error?

  right_expression.result
end

#success?Boolean

Returns:

  • (Boolean)


48
49
50
51
52
53
# File 'lib/convenient_service/service/plugins/can_have_connected_steps/entities/expressions/or.rb', line 48

def success?
  return true if left_expression.success?
  return false if left_expression.error?

  right_expression.success?
end

#to_argumentsConvenientService::Support::Arguments



142
143
144
# File 'lib/convenient_service/service/plugins/can_have_connected_steps/entities/expressions/or.rb', line 142

def to_arguments
  Support::Arguments.new(left_expression, right_expression)
end

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



108
109
110
# File 'lib/convenient_service/service/plugins/can_have_connected_steps/entities/expressions/or.rb', line 108

def with_organizer(organizer)
  copy(overrides: {args: {0 => left_expression.with_organizer(organizer), 1 => right_expression.with_organizer(organizer)}})
end