Class: ConvenientService::Core::Entities::Config::Entities::Concerns

Inherits:
Object
  • Object
show all
Defined in:
lib/convenient_service/core/entities/config/entities/concerns.rb,
lib/convenient_service/core/entities/config/entities/concerns/entities/stack.rb,
lib/convenient_service/core/entities/config/entities/concerns/entities/middleware.rb,
lib/convenient_service/core/entities/config/entities/concerns/entities/default_concern.rb,
lib/convenient_service/core/entities/config/entities/concerns/entities/middleware/commands/cast_middleware.rb

Defined Under Namespace

Modules: Entities

Instance Method Summary collapse

Constructor Details

#initialize(klass:) ⇒ void

Parameters:

  • klass (Class)


15
16
17
# File 'lib/convenient_service/core/entities/config/entities/concerns.rb', line 15

def initialize(klass:)
  @klass = klass
end

Instance Method Details

#==(other) ⇒ Boolean?

Parameters:

Returns:

  • (Boolean, nil)


103
104
105
106
107
108
109
110
# File 'lib/convenient_service/core/entities/config/entities/concerns.rb', line 103

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

  return false if klass != other.klass
  return false if stack != other.stack

  true
end

#class_method_defined?(method_name) ⇒ Boolean

Parameters:

  • method_name (Symbol, String)

Returns:

  • (Boolean)


45
46
47
# File 'lib/convenient_service/core/entities/config/entities/concerns.rb', line 45

def class_method_defined?(method_name)
  class_method_defined_in_class_methods_modules?(method_name)
end

#configure(&configuration_block) ⇒ ConvenientService::Core::Entities::Config::Entities::Concerns

Parameters:

  • configuration_block (Proc)

Returns:



73
74
75
76
77
# File 'lib/convenient_service/core/entities/config/entities/concerns.rb', line 73

def configure(&configuration_block)
  Utils::Proc.exec_config(configuration_block, stack)

  self
end

#include!Boolean

Includes concerns into klass when called for the first time. Does nothing for the subsequent calls.

Returns:

  • (Boolean)

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

See Also:



91
92
93
94
95
96
97
# File 'lib/convenient_service/core/entities/config/entities/concerns.rb', line 91

def include!
  return false if included?

  stack.dup.insert_before(0, Entities::DefaultConcern).call(klass: klass)

  true
end

#included?Boolean

Checks whether concerns are included into klass (include! was called at least once).

Returns:

  • (Boolean)


65
66
67
# File 'lib/convenient_service/core/entities/config/entities/concerns.rb', line 65

def included?
  klass.include?(Entities::DefaultConcern)
end

#instance_method_defined?(method_name) ⇒ Boolean

Parameters:

  • method_name (Symbol, String)

Returns:

  • (Boolean)


23
24
25
26
27
28
# File 'lib/convenient_service/core/entities/config/entities/concerns.rb', line 23

def instance_method_defined?(method_name)
  return true if instance_method_defined_in_instance_methods_modules?(method_name)
  return true if instance_method_defined_directly?(method_name)

  false
end

#private_class_method_defined?(method_name) ⇒ Boolean

Parameters:

  • method_name (Symbol, String)

Returns:

  • (Boolean)


53
54
55
# File 'lib/convenient_service/core/entities/config/entities/concerns.rb', line 53

def private_class_method_defined?(method_name)
  private_class_method_defined_in_class_methods_modules?(method_name)
end

#private_instance_method_defined?(method_name) ⇒ Boolean

Parameters:

  • method_name (Symbol, String)

Returns:

  • (Boolean)


34
35
36
37
38
39
# File 'lib/convenient_service/core/entities/config/entities/concerns.rb', line 34

def private_instance_method_defined?(method_name)
  return true if private_instance_method_defined_in_instance_methods_modules?(method_name)
  return true if private_instance_method_defined_directly?(method_name)

  false
end

#to_aArray<Module>

Returns concerns as plain modules.

Returns:

  • (Array<Module>)

    concerns as plain modules.



115
116
117
# File 'lib/convenient_service/core/entities/config/entities/concerns.rb', line 115

def to_a
  plain_concerns
end