module Purview::Mixins::Helpers

Public Instance Methods

blank?(value) click to toggle source
# File lib/purview/mixins/helpers.rb, line 4
def blank?(value)
  value.to_s.strip.length.zero?
end
coalesced(value, default) click to toggle source
# File lib/purview/mixins/helpers.rb, line 8
def coalesced(value, default)
  value.nil? ? default : value
end
filter_blank_values(hash) click to toggle source
# File lib/purview/mixins/helpers.rb, line 12
def filter_blank_values(hash)
  hash.reject { |_, value| blank?(value) }
end
filter_nil_values(hash) click to toggle source
# File lib/purview/mixins/helpers.rb, line 16
def filter_nil_values(hash)
  hash.reject { |_, value| value.nil? }
end
present?(value) click to toggle source
# File lib/purview/mixins/helpers.rb, line 20
def present?(value)
  !blank?(value)
end
timestamp() click to toggle source
# File lib/purview/mixins/helpers.rb, line 24
def timestamp
  Time.now
end
with_timestamp() { |timestamp| ... } click to toggle source
# File lib/purview/mixins/helpers.rb, line 28
def with_timestamp
  yield timestamp
end
zero?(value) click to toggle source
# File lib/purview/mixins/helpers.rb, line 32
def zero?(value)
  Integer(value).zero?
end