Class: Bridgetown::Foundation::QuestionableString

Inherits:
String
  • Object
show all
Defined in:
bridgetown-foundation/lib/bridgetown/foundation/questionable_string.rb

Instance Method Summary collapse

Dynamic Method Handling

This class handles dynamic methods through the method_missing method

#method_missing(method_name, *args) ⇒ Object



5
6
7
8
9
10
11
12
13
# File 'bridgetown-foundation/lib/bridgetown/foundation/questionable_string.rb', line 5

def method_missing(method_name, *args)
  value = method_name.to_s
  if value.end_with?("?")
    value.chop!
    return self == value
  end

  super
end

Instance Method Details

#respond_to_missing?(method_name, include_private = false) ⇒ Boolean

Returns:

  • (Boolean)


15
16
17
# File 'bridgetown-foundation/lib/bridgetown/foundation/questionable_string.rb', line 15

def respond_to_missing?(method_name, include_private = false)
  method_name.end_with?("?") || super
end