Module: Stackify::Utils

Defined in:
lib/stackify/utils/methods.rb

Class Method Summary collapse

Class Method Details

.current_minuteObject



3
4
5
# File 'lib/stackify/utils/methods.rb', line 3

def self.current_minute
  Time.now.utc.to_i/60
end

.do_only_if_authorized_and_mode_is_on(mode, &block) ⇒ Object



16
17
18
19
20
21
22
23
24
25
26
# File 'lib/stackify/utils/methods.rb', line 16

def self.do_only_if_authorized_and_mode_is_on mode, &block
  if Stackify.authorized?
    if is_mode_on? mode
      yield
    else
      Stackify.internal_log :warn, "#{caller[0]}: Skipped because mode - #{mode.to_s} is disabled at configuration"
    end
  else
    Stackify.internal_log :warn, "#{caller[0]}: Skipped due to authorization failure"
  end
end

.is_mode_on?(mode) ⇒ Boolean

Returns:

  • (Boolean)


12
13
14
# File 'lib/stackify/utils/methods.rb', line 12

def self.is_mode_on? mode
  Stackify.configuration.mode == Stackify::MODES[:both] || Stackify.configuration.mode == mode
end

.rounded_current_timeObject



7
8
9
10
# File 'lib/stackify/utils/methods.rb', line 7

def self.rounded_current_time
  t = Time.now.utc
  t - t.sec
end