Class: ConvenientService::Common::Plugins::CanHaveCallbacks::Entities::Callback

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

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(types:, block:, **extra_kwargs) ⇒ void

Parameters:



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

def initialize(types:, block:, **extra_kwargs)
  @types = Entities::TypeCollection.new(types: types)
  @block = block
  @source_location = extra_kwargs.fetch(:source_location) { block.source_location }
end

Instance Attribute Details

#blockObject (readonly)

Returns the value of attribute block.



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

def block
  @block
end

#source_locationObject (readonly)

Returns the value of attribute source_location.



25
26
27
# File 'lib/convenient_service/common/plugins/can_have_callbacks/entities/callback.rb', line 25

def source_location
  @source_location
end

#typesObject (readonly)

Returns the value of attribute types.



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

def types
  @types
end

Instance Method Details

#==(other) ⇒ Boolean?

Parameters:

  • other (Object)

    Can be any type.

Returns:

  • (Boolean, nil)


120
121
122
123
124
125
126
127
128
# File 'lib/convenient_service/common/plugins/can_have_callbacks/entities/callback.rb', line 120

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

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

  true
end

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

Returns Can be any type.

Returns:

  • (Object)

    Can be any type.



66
67
68
# File 'lib/convenient_service/common/plugins/can_have_callbacks/entities/callback.rb', line 66

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

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

Parameters:

  • context (Object)

    Can be any type.

Returns:



89
90
91
# File 'lib/convenient_service/common/plugins/can_have_callbacks/entities/callback.rb', line 89

def call_in_context(context)
  call_callback_in_context(context)
end

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

Parameters:

  • context (Object)

    Can be any type.

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

Returns:



100
101
102
# File 'lib/convenient_service/common/plugins/can_have_callbacks/entities/callback.rb', line 100

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::CanHaveCallbacks::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:



112
113
114
# File 'lib/convenient_service/common/plugins/can_have_callbacks/entities/callback.rb', line 112

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)


52
53
54
# File 'lib/convenient_service/common/plugins/can_have_callbacks/entities/callback.rb', line 52

def called?
  Utils.to_bool(@called)
end

#not_called?Boolean

Returns:

  • (Boolean)


59
60
61
# File 'lib/convenient_service/common/plugins/can_have_callbacks/entities/callback.rb', line 59

def not_called?
  !called?
end

#source_location_joined_by_colonString

Returns:

  • (String)


45
46
47
# File 'lib/convenient_service/common/plugins/can_have_callbacks/entities/callback.rb', line 45

def source_location_joined_by_colon
  source_location.join(":")
end

#to_procProc

Returns:

  • (Proc)


133
134
135
# File 'lib/convenient_service/common/plugins/can_have_callbacks/entities/callback.rb', line 133

def to_proc
  block
end