Class: ConvenientService::Common::Plugins::HasCallbacks::Entities::Callback

Inherits:
Object
  • Object
show all
Defined in:
lib/convenient_service/common/plugins/has_callbacks/entities/callback.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(types:, block:) ⇒ void



26
27
28
29
# File 'lib/convenient_service/common/plugins/has_callbacks/entities/callback.rb', line 26

def initialize(types:, block:)
  @types = Entities::TypeCollection.new(types: types)
  @block = block
end

Instance Attribute Details

#blockObject (readonly)

Returns the value of attribute block.



19
20
21
# File 'lib/convenient_service/common/plugins/has_callbacks/entities/callback.rb', line 19

def block
  @block
end

#typesObject (readonly)

Returns the value of attribute types.



13
14
15
# File 'lib/convenient_service/common/plugins/has_callbacks/entities/callback.rb', line 13

def types
  @types
end

Instance Method Details

#==(other) ⇒ Boolead

Parameters:

  • other (Object)

    Can be any type.

Returns:

  • (Boolead)


102
103
104
105
106
107
108
109
# File 'lib/convenient_service/common/plugins/has_callbacks/entities/callback.rb', line 102

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

  return false if types != other.types
  return false if block&.source_location != other.block&.source_location

  true
end

#callObject Also known as: yield, [], ===

Returns Can be any type.

Returns:

  • (Object)

    Can be any type.



48
49
50
# File 'lib/convenient_service/common/plugins/has_callbacks/entities/callback.rb', line 48

def call(...)
  call_callback(...)
end

#call_in_context(context) ⇒ ConvenientService::Common::Plugins::HasCallbacks::Entities::Callback

Parameters:

  • context (Object)

    Can be any type.

Returns:



71
72
73
# File 'lib/convenient_service/common/plugins/has_callbacks/entities/callback.rb', line 71

def call_in_context(context)
  call_callback_in_context(context)
end

#call_in_context_with_arguments(context, *args, **kwargs, &block) ⇒ ConvenientService::Common::Plugins::HasCallbacks::Entities::Callback

Parameters:

  • context (Object)

    Can be any type.

  • args (Array<Object>)
  • kwargs (Hash{Symbol => Object})
  • block (Proc, nil)

Returns:



82
83
84
# File 'lib/convenient_service/common/plugins/has_callbacks/entities/callback.rb', line 82

def call_in_context_with_arguments(context, *args, **kwargs, &block)
  call_callback_in_context(context, arguments(*args, **kwargs, &block))
end

#call_in_context_with_value_and_arguments(context, value, *args, **kwargs, &block) ⇒ ConvenientService::Common::Plugins::HasCallbacks::Entities::Callback

Parameters:

  • context (Object)

    Can be any type.

  • value (Object)

    Can be any type.

  • args (Array<Object>)
  • kwargs (Hash{Symbol => Object})
  • block (Proc, nil)

Returns:



94
95
96
# File 'lib/convenient_service/common/plugins/has_callbacks/entities/callback.rb', line 94

def call_in_context_with_value_and_arguments(context, value, *args, **kwargs, &block)
  call_callback_in_context(context, value, arguments(*args, **kwargs, &block))
end

#called?Boolean

Returns:

  • (Boolean)


34
35
36
# File 'lib/convenient_service/common/plugins/has_callbacks/entities/callback.rb', line 34

def called?
  Utils.to_bool(@called)
end

#not_called?Boolean

Returns:

  • (Boolean)


41
42
43
# File 'lib/convenient_service/common/plugins/has_callbacks/entities/callback.rb', line 41

def not_called?
  !called?
end

#to_procProc

Returns:

  • (Proc)


114
115
116
# File 'lib/convenient_service/common/plugins/has_callbacks/entities/callback.rb', line 114

def to_proc
  block
end