Module: TimestampStates
- Extended by:
- ActiveSupport::Concern
- Defined in:
- lib/timestamp_states.rb,
lib/timestamp_states/railtie.rb,
lib/timestamp_states/version.rb
Defined Under Namespace
Modules: ClassMethods Classes: Error, Railtie
Constant Summary collapse
- VERSION =
'1.0.3'
Instance Method Summary collapse
- #method_missing(method_name, *args, &block) ⇒ Object
- #respond_to_missing?(method_name, include_private = false) ⇒ Boolean
Dynamic Method Handling
This class handles dynamic methods through the method_missing method
#method_missing(method_name, *args, &block) ⇒ Object
98 99 100 101 102 103 104 105 106 107 108 109 110 111 |
# File 'lib/timestamp_states.rb', line 98 def method_missing(method_name, *args, &block) self.class.base_class..to_h.each do |column, | return (column) if method_name.to_s == "#{[:words][:past]}?" || method_name.to_s == [:words][:past].to_s return !(column) if method_name.to_s == "#{[:words][:past_not]}?" || method_name.to_s == [:words][:past_not].to_s return (column) if method_name.to_s == [:words][:action].to_s return (column) if method_name.to_s == [:words][:not_action].to_s return (column) if method_name.to_s == "#{[:words][:action]}!" return (column) if method_name.to_s == "#{[:words][:not_action]}!" return (column, args.first) if method_name.to_s == "#{[:words][:past]}=" return (column, !args.first) if method_name.to_s == "#{[:words][:past_not]}=" end super end |
Instance Method Details
#respond_to_missing?(method_name, include_private = false) ⇒ Boolean
113 114 115 116 117 118 119 120 121 122 |
# File 'lib/timestamp_states.rb', line 113 def respond_to_missing?(method_name, include_private = false) self.class.base_class..to_h.each_value do || return true if method_name.to_s == "#{[:words][:past]}?" || method_name.to_s == [:words][:past].to_s return true if method_name.to_s == [:words][:action].to_s || method_name.to_s == "#{[:words][:action]}!" return true if method_name.to_s == [:words][:not_action].to_s || method_name.to_s == "#{[:words][:not_action]}!" return true if ["#{[:words][:past]}=", "#{[:words][:past_not]}="].include?(method_name.to_s) end super end |