Class: SelfishAssociations::Nilifier
- Inherits:
-
BasicObject
- Defined in:
- lib/selfish_associations/utils/nilifier.rb
Instance Method Summary
collapse
Constructor Details
#initialize(object) ⇒ Nilifier
Returns a new instance of Nilifier.
3
4
5
|
# File 'lib/selfish_associations/utils/nilifier.rb', line 3
def initialize(object)
@object = object
end
|
Dynamic Method Handling
This class handles dynamic methods through the method_missing method
#method_missing(method, *args) ⇒ Object
19
20
21
22
|
# File 'lib/selfish_associations/utils/nilifier.rb', line 19
def method_missing(method, *args)
result = @object.respond_to?(method) ? @object.public_send(method, *args) : nil
::SelfishAssociations::Nilifier.new(result)
end
|
Instance Method Details
#inspect ⇒ Object
7
8
9
|
# File 'lib/selfish_associations/utils/nilifier.rb', line 7
def inspect
@object.inspect + " (nil-safe)"
end
|
#respond_to?(method) ⇒ Boolean
15
16
17
|
# File 'lib/selfish_associations/utils/nilifier.rb', line 15
def respond_to?(method)
true
end
|
#unnilify ⇒ Object
11
12
13
|
# File 'lib/selfish_associations/utils/nilifier.rb', line 11
def unnilify
@object
end
|