Class: Munificent::BundleTier

Inherits:
ApplicationRecord show all
Defined in:
app/models/munificent/bundle_tier.rb

Instance Method Summary collapse

Methods inherited from ApplicationRecord

#to_s

Instance Method Details

#availability_textObject

rubocop:disable Metrics/CyclomaticComplexity, Metrics/PerceivedComplexity



15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
# File 'app/models/munificent/bundle_tier.rb', line 15

def availability_text # rubocop:disable Metrics/CyclomaticComplexity, Metrics/PerceivedComplexity
  return unless starts_at || ends_at

  if starts_at && starts_at > Time.now.utc
    if ends_at
      "Available between #{time(starts_at)} and #{time(ends_at)}"
    else
      "Available from #{time(starts_at)}"
    end
  elsif ends_at
    if ends_at > Time.now.utc
      "Available until #{time(ends_at)}"
    else
      "No longer available"
    end
  end
end

#blank?Boolean

Returns:

  • (Boolean)


33
34
35
# File 'app/models/munificent/bundle_tier.rb', line 33

def blank?
  new_record? && name.blank? && price.zero? && bundle_tier_games.none?
end