Class: Centaman::Filter
- Inherits:
-
Object
- Object
- Centaman::Filter
- Defined in:
- lib/centaman/filter.rb
Overview
:nodoc:
Instance Attribute Summary collapse
-
#booking_time_id ⇒ Object
readonly
Returns the value of attribute booking_time_id.
-
#booking_type_id ⇒ Object
readonly
Returns the value of attribute booking_type_id.
-
#email ⇒ Object
readonly
Returns the value of attribute email.
-
#end_date ⇒ Object
readonly
Returns the value of attribute end_date.
-
#member_code ⇒ Object
readonly
Returns the value of attribute member_code.
-
#membership_type_id ⇒ Object
readonly
Returns the value of attribute membership_type_id.
-
#start_date ⇒ Object
readonly
Returns the value of attribute start_date.
Instance Method Summary collapse
- #add_ons ⇒ Object
- #booking_times ⇒ Object
- #booking_types ⇒ Object
- #capacity ⇒ Object
- #find_add_on(membership_type_id, id) ⇒ Object
- #find_booking_time(booking_time_id) ⇒ Object
- #find_booking_type(booking_type_id) ⇒ Object
- #find_member(args) ⇒ Object
- #find_membership_type(membership_type_id) ⇒ Object
- #gift_tickets ⇒ Object
-
#initialize(args = {}) ⇒ Filter
constructor
A new instance of Filter.
- #membership_types ⇒ Object
- #tickets ⇒ Object
Constructor Details
#initialize(args = {}) ⇒ Filter
Returns a new instance of Filter.
7 8 9 10 11 12 13 14 15 |
# File 'lib/centaman/filter.rb', line 7 def initialize(args = {}) @booking_type_id = args[:booking_type_id].try(:to_i) @booking_time_id = args[:booking_time_id].try(:to_i) @start_date = args[:start_date] @end_date = args[:end_date] @membership_type_id = args.fetch(:membership_type_id, nil).try(:to_i) @member_code = args.fetch(:member_code, nil).try(:to_i) @email = args.fetch(:email, nil) end |
Instance Attribute Details
#booking_time_id ⇒ Object (readonly)
Returns the value of attribute booking_time_id.
4 5 6 |
# File 'lib/centaman/filter.rb', line 4 def booking_time_id @booking_time_id end |
#booking_type_id ⇒ Object (readonly)
Returns the value of attribute booking_type_id.
4 5 6 |
# File 'lib/centaman/filter.rb', line 4 def booking_type_id @booking_type_id end |
#email ⇒ Object (readonly)
Returns the value of attribute email.
4 5 6 |
# File 'lib/centaman/filter.rb', line 4 def email @email end |
#end_date ⇒ Object (readonly)
Returns the value of attribute end_date.
4 5 6 |
# File 'lib/centaman/filter.rb', line 4 def end_date @end_date end |
#member_code ⇒ Object (readonly)
Returns the value of attribute member_code.
4 5 6 |
# File 'lib/centaman/filter.rb', line 4 def member_code @member_code end |
#membership_type_id ⇒ Object (readonly)
Returns the value of attribute membership_type_id.
4 5 6 |
# File 'lib/centaman/filter.rb', line 4 def membership_type_id @membership_type_id end |
#start_date ⇒ Object (readonly)
Returns the value of attribute start_date.
4 5 6 |
# File 'lib/centaman/filter.rb', line 4 def start_date @start_date end |
Instance Method Details
#add_ons ⇒ Object
59 60 61 |
# File 'lib/centaman/filter.rb', line 59 def add_ons Centaman::Service::AddOn.new(membership_type_id: membership_type_id).objects end |
#booking_times ⇒ Object
34 35 36 37 38 39 40 |
# File 'lib/centaman/filter.rb', line 34 def booking_times @booking_times ||= Centaman::Service::BookingTime.new( booking_type_id: booking_type_id, start_date: start_date, end_date: end_date ).objects end |
#booking_types ⇒ Object
26 27 28 |
# File 'lib/centaman/filter.rb', line 26 def booking_types @booking_types ||= Centaman::Service::BookingType.new.objects end |
#capacity ⇒ Object
46 47 48 |
# File 'lib/centaman/filter.rb', line 46 def capacity @capacity ||= Centaman::Service::Capacity.new(booking_time_id: booking_time_id, start_date: start_date).objects.first end |
#find_add_on(membership_type_id, id) ⇒ Object
63 64 65 |
# File 'lib/centaman/filter.rb', line 63 def find_add_on(membership_type_id, id) Centaman::Service::AddOn.find(membership_type_id, id) end |
#find_booking_time(booking_time_id) ⇒ Object
21 22 23 24 |
# File 'lib/centaman/filter.rb', line 21 def find_booking_time(booking_time_id) raise "booking_time_id is required for find_booking_time method of #{self.class.name} class" if booking_time_id.nil? booking_times.detect { |c| c.id.to_s == booking_time_id.to_s } end |
#find_booking_type(booking_type_id) ⇒ Object
17 18 19 |
# File 'lib/centaman/filter.rb', line 17 def find_booking_type(booking_type_id) booking_types.detect { |c| c.booking_type_id == booking_type_id } end |
#find_member(args) ⇒ Object
67 68 69 70 71 72 |
# File 'lib/centaman/filter.rb', line 67 def find_member(args) Centaman::Service::Member.new( member_code: args[:member_code], email: args[:email] ).objects end |
#find_membership_type(membership_type_id) ⇒ Object
54 55 56 57 |
# File 'lib/centaman/filter.rb', line 54 def find_membership_type(membership_type_id) raise "membership_type_id is required for find_membership_type method of #{self.class.name} class" if membership_type_id.nil? Centaman::Service::MembershipType.find(membership_type_id) end |
#gift_tickets ⇒ Object
42 43 44 |
# File 'lib/centaman/filter.rb', line 42 def gift_tickets @gift_tickets ||= Centaman::Service::GiftTicket.new.objects end |
#membership_types ⇒ Object
50 51 52 |
# File 'lib/centaman/filter.rb', line 50 def membership_types Centaman::Service::MembershipType.new.objects end |
#tickets ⇒ Object
30 31 32 |
# File 'lib/centaman/filter.rb', line 30 def tickets @tickets ||= Centaman::Service::TicketType.new(booking_time_id: booking_time_id).objects end |