Class: RestaurantTypes::ChargeImmediately

Inherits:
Object
  • Object
show all
Defined in:
app/my_lib/restaurant_types/charge_immediately.rb

Overview

Currently only used in cucumber test Used for set restaurant as charge immediately Validate the required fields are expected by call #valid?

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(restaurant_id, options = {}) ⇒ ChargeImmediately

Returns a new instance of ChargeImmediately.



20
21
22
23
24
25
26
27
28
# File 'app/my_lib/restaurant_types/charge_immediately.rb', line 20

def initialize(restaurant_id, options = {})
  @errors = ActiveModel::Errors.new(self)
  self.restaurant = Restaurant.find(restaurant_id)
  options.each_pair do |key, value|
    method = "#{key}=".to_sym
    send(method, value) if respond_to?(:method)
  end
  self
end

Instance Attribute Details

#adult_charge_amountObject

Returns the value of attribute adult_charge_amount.



17
18
19
# File 'app/my_lib/restaurant_types/charge_immediately.rb', line 17

def adult_charge_amount
  @adult_charge_amount
end

#errorsObject (readonly)

Returns the value of attribute errors.



43
44
45
# File 'app/my_lib/restaurant_types/charge_immediately.rb', line 43

def errors
  @errors
end

#kids_charge_amountObject

Returns the value of attribute kids_charge_amount.



17
18
19
# File 'app/my_lib/restaurant_types/charge_immediately.rb', line 17

def kids_charge_amount
  @kids_charge_amount
end

#min_party_sizeObject

Returns the value of attribute min_party_size.



17
18
19
# File 'app/my_lib/restaurant_types/charge_immediately.rb', line 17

def min_party_size
  @min_party_size
end

#pricing_typeObject

Returns the value of attribute pricing_type.



17
18
19
# File 'app/my_lib/restaurant_types/charge_immediately.rb', line 17

def pricing_type
  @pricing_type
end

#restaurantObject

Returns the value of attribute restaurant.



17
18
19
# File 'app/my_lib/restaurant_types/charge_immediately.rb', line 17

def restaurant
  @restaurant
end

Instance Method Details

#saveObject



39
40
41
# File 'app/my_lib/restaurant_types/charge_immediately.rb', line 39

def save
  valid? && restaurant.save
end

#valid?Boolean

Returns:

  • (Boolean)


30
31
32
33
34
35
36
37
# File 'app/my_lib/restaurant_types/charge_immediately.rb', line 30

def valid?
  if restaurant.min_party_size_to_charge.to_i.positive? &&
     restaurant.cc_immediate_charge_amount.present?
    true
  else
    assert_required_attrs
  end
end