Class: RestaurantTypes::ChargeImmediately
- Inherits:
-
Object
- Object
- RestaurantTypes::ChargeImmediately
- 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
-
#adult_charge_amount ⇒ Object
Returns the value of attribute adult_charge_amount.
-
#errors ⇒ Object
readonly
Returns the value of attribute errors.
-
#kids_charge_amount ⇒ Object
Returns the value of attribute kids_charge_amount.
-
#min_party_size ⇒ Object
Returns the value of attribute min_party_size.
-
#pricing_type ⇒ Object
Returns the value of attribute pricing_type.
-
#restaurant ⇒ Object
Returns the value of attribute restaurant.
Instance Method Summary collapse
-
#initialize(restaurant_id, options = {}) ⇒ ChargeImmediately
constructor
A new instance of ChargeImmediately.
- #save ⇒ Object
- #valid? ⇒ Boolean
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, = {}) @errors = ActiveModel::Errors.new(self) self.restaurant = Restaurant.find(restaurant_id) .each_pair do |key, value| method = "#{key}=".to_sym send(method, value) if respond_to?(:method) end self end |
Instance Attribute Details
#adult_charge_amount ⇒ Object
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 |
#errors ⇒ Object (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_amount ⇒ Object
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_size ⇒ Object
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_type ⇒ Object
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 |
#restaurant ⇒ Object
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
#save ⇒ Object
39 40 41 |
# File 'app/my_lib/restaurant_types/charge_immediately.rb', line 39 def save valid? && restaurant.save end |
#valid? ⇒ 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 |