mirror of
https://github.com/LaCasemate/fab-manager.git
synced 2024-11-29 10:24:20 +01:00
improved ruby syntax to match coding rules in some services
This commit is contained in:
parent
21c7484396
commit
4dfe02bebf
@ -1,19 +1,20 @@
|
||||
module Reservations
|
||||
class Reserve
|
||||
attr_accessor :user_id, :operator_id
|
||||
# frozen_string_literal: true
|
||||
|
||||
def initialize(user_id, operator_id)
|
||||
@user_id = user_id
|
||||
@operator_id = operator_id
|
||||
end
|
||||
# Provides helper methods for Reservation actions
|
||||
class Reservations::Reserve
|
||||
attr_accessor :user_id, :operator_id
|
||||
|
||||
def pay_and_save(reservation, payment_method, coupon)
|
||||
reservation.user_id = user_id
|
||||
if payment_method == :local
|
||||
reservation.save_with_local_payment(operator_id, coupon)
|
||||
elsif payment_method == :stripe
|
||||
reservation.save_with_payment(operator_id, coupon)
|
||||
end
|
||||
def initialize(user_id, operator_id)
|
||||
@user_id = user_id
|
||||
@operator_id = operator_id
|
||||
end
|
||||
|
||||
def pay_and_save(reservation, payment_method, coupon)
|
||||
reservation.user_id = user_id
|
||||
if payment_method == :local
|
||||
reservation.save_with_local_payment(operator_id, coupon)
|
||||
elsif payment_method == :stripe
|
||||
reservation.save_with_payment(operator_id, coupon)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
@ -1,34 +1,35 @@
|
||||
module Subscriptions
|
||||
class Subscribe
|
||||
attr_accessor :user_id, :operator_id
|
||||
# frozen_string_literal: true
|
||||
|
||||
def initialize(user_id, operator_id)
|
||||
@user_id = user_id
|
||||
@operator_id = operator_id
|
||||
end
|
||||
# Provides helper methods for Subscription actions
|
||||
class Subscriptions::Subscribe
|
||||
attr_accessor :user_id, :operator_id
|
||||
|
||||
def pay_and_save(subscription, payment_method, coupon, invoice)
|
||||
subscription.user_id = user_id
|
||||
if payment_method == :local
|
||||
subscription.save_with_local_payment(operator_id, invoice, coupon)
|
||||
elsif payment_method == :stripe
|
||||
subscription.save_with_payment(operator_id, invoice, coupon)
|
||||
end
|
||||
end
|
||||
def initialize(user_id, operator_id)
|
||||
@user_id = user_id
|
||||
@operator_id = operator_id
|
||||
end
|
||||
|
||||
def extend_subscription(subscription, new_expiration_date, free_days)
|
||||
return subscription.free_extend(new_expiration_date) if free_days
|
||||
|
||||
new_sub = Subscription.create(
|
||||
plan_id: subscription.plan_id,
|
||||
user_id: subscription.user_id,
|
||||
expiration_date: new_expiration_date
|
||||
)
|
||||
if new_sub.save
|
||||
new_sub.user.generate_subscription_invoice(operator_id)
|
||||
return new_sub
|
||||
end
|
||||
false
|
||||
def pay_and_save(subscription, payment_method, coupon, invoice)
|
||||
subscription.user_id = user_id
|
||||
if payment_method == :local
|
||||
subscription.save_with_local_payment(operator_id, invoice, coupon)
|
||||
elsif payment_method == :stripe
|
||||
subscription.save_with_payment(operator_id, invoice, coupon)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
def extend_subscription(subscription, new_expiration_date, free_days)
|
||||
return subscription.free_extend(new_expiration_date) if free_days
|
||||
|
||||
new_sub = Subscription.create(
|
||||
plan_id: subscription.plan_id,
|
||||
user_id: subscription.user_id,
|
||||
expiration_date: new_expiration_date
|
||||
)
|
||||
if new_sub.save
|
||||
new_sub.user.generate_subscription_invoice(operator_id)
|
||||
return new_sub
|
||||
end
|
||||
false
|
||||
end
|
||||
end
|
Loading…
Reference in New Issue
Block a user