Class: ConvenientService::Service::Plugins::CanHaveSteps::Entities::StepCollection

Inherits:
Object
  • Object
show all
Includes:
Enumerable
Defined in:
lib/convenient_service/service/plugins/can_have_steps/entities/step_collection.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(steps: []) ⇒ 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.

Parameters:



25
26
27
# File 'lib/convenient_service/service/plugins/can_have_steps/entities/step_collection.rb', line 25

def initialize(steps: [])
  @steps = steps
end

Instance Attribute Details

#stepsObject (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.



17
18
19
# File 'lib/convenient_service/service/plugins/can_have_steps/entities/step_collection.rb', line 17

def steps
  @steps
end

Instance Method Details

#<<(step) ⇒ ConvenientService::Service::Plugins::CanHaveSteps::Entities::StepCollection

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.



89
90
91
92
93
# File 'lib/convenient_service/service/plugins/can_have_steps/entities/step_collection.rb', line 89

def <<(step)
  steps << step.copy(overrides: {kwargs: {index: next_available_index}})

  self
end

#==(other) ⇒ Boolean?

Parameters:

  • other (Object)

    Can be any type.

Returns:

  • (Boolean, nil)


101
102
103
104
105
106
107
# File 'lib/convenient_service/service/plugins/can_have_steps/entities/step_collection.rb', line 101

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

  return false if steps != other.steps

  true
end

#[](index) ⇒ ConvenientService::Service::Plugins::CanHaveSteps::Entities::Step

Note:

Works in a similar way as Array#[].

Returns step by index.



79
80
81
# File 'lib/convenient_service/service/plugins/can_have_steps/entities/step_collection.rb', line 79

def [](index)
  steps[index]
end

#commit!Boolean

Returns true if called for the first time, false otherwise (similarly as Kernel#require).

Returns:

  • (Boolean)

    true if called for the first time, false otherwise (similarly as Kernel#require).

See Also:



41
42
43
44
45
46
47
# File 'lib/convenient_service/service/plugins/can_have_steps/entities/step_collection.rb', line 41

def commit!
  return false if committed?

  steps.each(&:define!).freeze

  true
end

#committed?Boolean

Returns:

  • (Boolean)


54
55
56
# File 'lib/convenient_service/service/plugins/can_have_steps/entities/step_collection.rb', line 54

def committed?
  steps.frozen?
end

#each(&block) ⇒ Array<ConvenientService::Service::Plugins::CanHaveSteps::Entities::Step>, Enumerator

Parameters:

  • block (Proc, nil)

Returns:



64
65
66
# File 'lib/convenient_service/service/plugins/can_have_steps/entities/step_collection.rb', line 64

def each(&block)
  steps.each(&block)
end