Module: Urge::InstanceMethods

Defined in:
lib/urge.rb

Instance Method Summary collapse

Instance Method Details

#urge(name, options = {}) ⇒ Object

Takes action and reschedules itself. That is all, and that is enough!



89
90
91
92
93
94
95
96
97
# File 'lib/urge.rb', line 89

def urge( name, options = {} )

  return false unless urgent?( name )

  interval = self.send( self.class.urge_schedules[name][:action].to_sym, options )
  urge_reschedule( name, interval ? interval.from_now : nil )
  true

end

#urge_reschedule(name, _when) ⇒ Object



83
84
85
86
# File 'lib/urge.rb', line 83

def urge_reschedule( name, _when )
  urge_logger.debug "ScheduledTask#reschedule about to reschedule for #{_when}"
  self.send( "#{urge_attr_name(name)}=", _when )
end

#urgent?(name) ⇒ Boolean

Returns:

  • (Boolean)


78
79
80
81
# File 'lib/urge.rb', line 78

def urgent?( name )
  ts = self.send( urge_attr_name( name ) )
  ts ? (DateTime.now >= ts) : false
end