Class: Endeavour
- Inherits:
-
Object
- Object
- Endeavour
- Defined in:
- lib/endeavour.rb,
lib/endeavour/railtie.rb,
lib/endeavour/version.rb,
lib/endeavour/core_ext.rb,
lib/endeavour/core_ext/object/try.rb,
lib/endeavour/core_ext/nil_class/try.rb
Defined Under Namespace
Modules: CoreExt Classes: Railtie
Constant Summary collapse
- VERSION =
'1.0.1'
Class Method Summary collapse
-
.call(object, method, *args, &block) ⇒ Object
Verb: Try hard to do or achieve something.
- .hook! ⇒ Object
- .remove_hook! ⇒ Object
Instance Method Summary collapse
-
#initialize(object) ⇒ Endeavour
constructor
Noun: An attempt to achieve a goal.
- #method_missing(method, *args, &block) ⇒ Object
Constructor Details
#initialize(object) ⇒ Endeavour
Noun: An attempt to achieve a goal.
11 12 13 |
# File 'lib/endeavour.rb', line 11 def initialize(object) @object = object end |
Dynamic Method Handling
This class handles dynamic methods through the method_missing method
#method_missing(method, *args, &block) ⇒ Object
21 22 23 |
# File 'lib/endeavour.rb', line 21 def method_missing(method, *args, &block) self.class.call(@object, method, *args, &block) end |
Class Method Details
.call(object, method, *args, &block) ⇒ Object
Verb: Try hard to do or achieve something.
6 7 8 |
# File 'lib/endeavour.rb', line 6 def self.call(object, method, *args, &block) object.send(method, *args, &block) if object.respond_to?(method) end |
.hook! ⇒ Object
5 6 7 8 9 |
# File 'lib/endeavour/core_ext.rb', line 5 def self.hook! return if defined?(@try_removed) Object.prepend CoreExt::Object::Try NilClass.prepend CoreExt::NilClass::Try end |
.remove_hook! ⇒ Object
11 12 13 14 15 |
# File 'lib/endeavour/core_ext.rb', line 11 def self.remove_hook! CoreExt::Object::Try.send(:remove_method, :try) CoreExt::NilClass::Try.send(:remove_method, :try) @try_removed = true end |