Class: Burgundy::Guard

Inherits:
Object
  • Object
show all
Defined in:
lib/burgundy/guard.rb

Instance Method Summary collapse

Constructor Details

#initialize(item) ⇒ Guard

Returns a new instance of Guard.



5
6
7
# File 'lib/burgundy/guard.rb', line 5

def initialize(item)
  @item = item
end

Dynamic Method Handling

This class handles dynamic methods through the method_missing method

#method_missing(name) ⇒ Object

rubocop:disable Style/MethodMissingSuper

Raises:

  • (ArgumentError)


9
10
11
12
13
14
15
16
17
18
# File 'lib/burgundy/guard.rb', line 9

def method_missing(name, *) # rubocop:disable Style/MethodMissingSuper
  class_name = @item.class.name || @item.class.inspect

  error_message = %W[
    #{class_name} was initialized without a delegating object and
    didn't implement #{class_name}##{name}
  ].join(" ")

  raise ArgumentError, "#{error_message}\n#{caller[1]}"
end

Instance Method Details

#respond_to_missing?Boolean

Returns:

  • (Boolean)


20
21
22
# File 'lib/burgundy/guard.rb', line 20

def respond_to_missing?(*)
  true
end