Module: Past
- Extended by:
- Checker
- Defined in:
- lib/past/checker.rb,
lib/past/checker/version.rb
Defined Under Namespace
Modules: Checker
Constant Summary
Constants included
from Checker
Checker::VERSION
Class Method Summary
collapse
Instance Method Summary
collapse
Methods included from Checker
checker_attribute, ll_at_attribute_presence?, ll_attribute_presence?, will_at_attribute_presence?, will_attribute_presence?
Dynamic Method Handling
This class handles dynamic methods through the method_missing method
#method_missing(name, *args, &block) ⇒ Object
14
15
16
17
|
# File 'lib/past/checker.rb', line 14
def method_missing(name, *args, &block)
return send(name) if define_past_checker(name) && respond_to?(name)
super
end
|
Class Method Details
.included(klass) ⇒ Object
55
56
57
|
# File 'lib/past/checker.rb', line 55
def self.included(klass)
klass.extend Checker
end
|
Instance Method Details
#define_past_checker(name) ⇒ Object
2
3
4
5
6
7
8
9
10
11
12
|
# File 'lib/past/checker.rb', line 2
def define_past_checker(name)
attribute = self.class.checker_attribute(name)
return false if attribute.nil?
self.class.class_eval do
define_method name do
it = send(attribute)
return nil if it.nil?
(Time.try(:zone).try(:now) || Time.now) > it
end
end
end
|
#respond_to_missing?(name, *args, &block) ⇒ Boolean
19
20
21
22
23
|
# File 'lib/past/checker.rb', line 19
def respond_to_missing?(name, *args, &block)
super unless name.to_s.last == '?'
return true unless self.class.checker_attribute(name).nil?
super
end
|