Class: SubscriptionClientSubscription

Inherits:
ActiveRecord::Base
  • Object
show all
Defined in:
app/models/subscription_client_subscription.rb

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.update_periodObject



32
33
34
# File 'app/models/subscription_client_subscription.rb', line 32

def self.update_period
  Time.zone.now - 2.days
end

Instance Method Details

#activeObject



16
17
18
# File 'app/models/subscription_client_subscription.rb', line 16

def active
  subscribed && updated_at.to_datetime > self.class.update_period.to_datetime
end

#deactivate!Object



20
21
22
# File 'app/models/subscription_client_subscription.rb', line 20

def deactivate!
  update(subscribed: false)
end

#resource_nameObject



24
25
26
# File 'app/models/subscription_client_subscription.rb', line 24

def resource_name
  resource.name
end

#supplier_nameObject



28
29
30
# File 'app/models/subscription_client_subscription.rb', line 28

def supplier_name
  resource.supplier.name
end