Class: ConvenientService::Core::Entities::Config::Commands::TrackMethodMissingCommitTrigger

Inherits:
Support::Command
  • Object
show all
Defined in:
lib/convenient_service/core/entities/config/commands/track_method_missing_commit_trigger.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods inherited from Support::Command

[], call

Constructor Details

#initialize(config:, trigger:) ⇒ void



26
27
28
29
# File 'lib/convenient_service/core/entities/config/commands/track_method_missing_commit_trigger.rb', line 26

def initialize(config:, trigger:)
  @config = config
  @trigger = trigger
end

Instance Attribute Details

#configObject (readonly)

Returns the value of attribute config.



13
14
15
# File 'lib/convenient_service/core/entities/config/commands/track_method_missing_commit_trigger.rb', line 13

def config
  @config
end

#triggerObject (readonly)

Returns the value of attribute trigger.



19
20
21
# File 'lib/convenient_service/core/entities/config/commands/track_method_missing_commit_trigger.rb', line 19

def trigger
  @trigger
end

Instance Method Details

#callvoid

This method returns an undefined value.



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

def call
  return unless method_missing_trigger_valid?
  return if method_missing_commits_counter_incremented?

  ::ConvenientService.raise Exceptions::TooManyCommitsFromMethodMissing.new(config: config)
end

#method_missing_commits_counter_incremented?Boolean

Returns:

  • (Boolean)


51
52
53
# File 'lib/convenient_service/core/entities/config/commands/track_method_missing_commit_trigger.rb', line 51

def method_missing_commits_counter_incremented?
  Utils.memoize_including_falsy_values(self, :@method_missing_commits_counter_incremented) { config.method_missing_commits_counter.bincrement }
end

#method_missing_trigger_valid?Boolean

Returns:

  • (Boolean)


44
45
46
# File 'lib/convenient_service/core/entities/config/commands/track_method_missing_commit_trigger.rb', line 44

def method_missing_trigger_valid?
  method_missing_triggers.any?(trigger)
end

#method_missing_triggersArray<ConvenientService::Support::UniqueValue>



58
59
60
61
62
63
# File 'lib/convenient_service/core/entities/config/commands/track_method_missing_commit_trigger.rb', line 58

def method_missing_triggers
  @method_missing_triggers ||= [
    Constants::Triggers::INSTANCE_METHOD_MISSING,
    Constants::Triggers::CLASS_METHOD_MISSING
  ]
end