Class: ConvenientService::Feature::Plugins::CanHaveStubbedEntries::Entities::ValueMock

Inherits:
Object
  • Object
show all
Defined in:
lib/convenient_service/feature/plugins/can_have_stubbed_entries/entities/value_mock.rb

Overview

Since:

  • 1.0.0

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(value:, feature_class: nil, entry_name: nil, arguments: nil) ⇒ void

Parameters:

Since:

  • 1.0.0



27
28
29
30
31
32
# File 'lib/convenient_service/feature/plugins/can_have_stubbed_entries/entities/value_mock.rb', line 27

def initialize(value:, feature_class: nil, entry_name: nil, arguments: nil)
  @value = value
  @feature_class = feature_class
  @entry_name = entry_name
  @arguments = arguments
end

Instance Attribute Details

#valueObject (readonly)

Since:

  • 1.0.0



18
19
20
# File 'lib/convenient_service/feature/plugins/can_have_stubbed_entries/entities/value_mock.rb', line 18

def value
  @value
end

Instance Method Details

#==(other) ⇒ Boolean?

Parameters:

  • other (Object)

    Can be any type.

Returns:

  • (Boolean, nil)

Since:

  • 1.0.0



73
74
75
76
77
78
79
80
81
82
# File 'lib/convenient_service/feature/plugins/can_have_stubbed_entries/entities/value_mock.rb', line 73

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

  return false if value != other.value
  return false if feature_class != other.feature_class
  return false if entry_name != other.entry_name
  return false if arguments != other.arguments

  true
end

#for(feature_class, entry_name, arguments) ⇒ ConvenientService::Feature::Plugins::CanHaveStubbedEntries::Entities::ValueMock

Parameters:

Returns:

Since:

  • 1.0.0



40
41
42
# File 'lib/convenient_service/feature/plugins/can_have_stubbed_entries/entities/value_mock.rb', line 40

def for(feature_class, entry_name, arguments)
  self.class.new(value: value, feature_class: feature_class, entry_name: entry_name, arguments: arguments)
end

#register(&block) ⇒ ConvenientService::Feature::Plugins::CanHaveStubbedEntries::Entities::ValueMock

Parameters:

  • block (Proc, nil)

Returns:

Since:

  • 1.0.0



48
49
50
51
52
53
54
55
56
57
58
# File 'lib/convenient_service/feature/plugins/can_have_stubbed_entries/entities/value_mock.rb', line 48

def register(&block)
  Commands::SetFeatureStubbedEntry[feature: feature_class, entry: entry_name, arguments: arguments, value: value]

  return self unless block

  begin
    yield
  ensure
    Commands::DeleteFeatureStubbedEntry[feature: feature_class, entry: entry_name, arguments: arguments]
  end
end

#unregisterConvenientService::Feature::Plugins::CanHaveStubbedEntries::Entities::ValueMock



63
64
65
66
67
# File 'lib/convenient_service/feature/plugins/can_have_stubbed_entries/entities/value_mock.rb', line 63

def unregister
  Commands::DeleteFeatureStubbedEntry[feature: feature_class, entry: entry_name, arguments: arguments]

  self
end