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

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

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods inherited from Base

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

Methods included from ConvenientService::Support::Copyable

#copy

Methods included from ConvenientService::Support::AbstractMethod

abstract_method

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/and.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/and.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/and.rb', line 20

def right_expression
  @right_expression
end

Instance Method Details

#==(other) ⇒ Boolean?

Parameters:

  • other (Object)

    Can be any type.

Returns:

  • (Boolean, nil)


115
116
117
118
119
120
121
122
# File 'lib/convenient_service/service/plugins/can_have_connected_steps/entities/expressions/and.rb', line 115

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

#and?Boolean

Returns:

  • (Boolean)


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

def and?
  true
end

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



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

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

  right_expression.each_evaluated_step(&block) if left_expression.success?

  self
end

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



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

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

  self
end

#error?Boolean

Returns:

  • (Boolean)


59
60
61
62
63
64
# File 'lib/convenient_service/service/plugins/can_have_connected_steps/entities/expressions/and.rb', line 59

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

  right_expression.error?
end

#failure?Boolean

Returns:

  • (Boolean)


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

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

  right_expression.failure?
end

#inspectString

Returns:

  • (String)


100
101
102
# File 'lib/convenient_service/service/plugins/can_have_connected_steps/entities/expressions/and.rb', line 100

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

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



35
36
37
# File 'lib/convenient_service/service/plugins/can_have_connected_steps/entities/expressions/and.rb', line 35

def result
  left_expression.success? ? right_expression.result : left_expression.result
end

#success?Boolean

Returns:

  • (Boolean)


42
43
44
# File 'lib/convenient_service/service/plugins/can_have_connected_steps/entities/expressions/and.rb', line 42

def success?
  left_expression.success? && right_expression.success?
end

#to_argumentsConvenientService::Support::Arguments



127
128
129
# File 'lib/convenient_service/service/plugins/can_have_connected_steps/entities/expressions/and.rb', line 127

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

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



93
94
95
# File 'lib/convenient_service/service/plugins/can_have_connected_steps/entities/expressions/and.rb', line 93

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