Module: SpreeCmCommissioner::KycBitwise
- Extended by:
- ActiveSupport::Concern
- Included in:
- Guest
- Defined in:
- app/models/concerns/spree_cm_commissioner/kyc_bitwise.rb
Constant Summary collapse
- BIT_FIELDS =
{ guest_name: 0b1, guest_gender: 0b10, guest_dob: 0b100, guest_occupation: 0b1000, guest_id_card: 0b10000, guest_nationality: 0b100000, guest_age: 0b1000000, guest_emergency_contact: 0b10000000, guest_organization: 0b100000000, guest_expectation: 0b1000000000, guest_social_contact: 0b10000000000, guest_address: 0b100000000000, guest_phone_number: 0b1000000000000 }.freeze
- ORDERED_BIT_FIELDS =
%i[ guest_name guest_gender guest_phone_number guest_dob guest_occupation guest_nationality guest_age guest_emergency_contact guest_organization guest_social_contact guest_address guest_expectation guest_id_card ].freeze
Instance Method Summary collapse
- #available_social_contact_platforms ⇒ Object
- #kyc? ⇒ Boolean
- #kyc_fields ⇒ Object
- #kyc_value_enabled?(bit_value) ⇒ Boolean
- #unordered_kyc_fields ⇒ Object
Instance Method Details
#available_social_contact_platforms ⇒ Object
59 60 61 62 |
# File 'app/models/concerns/spree_cm_commissioner/kyc_bitwise.rb', line 59 def platforms = SpreeCmCommissioner::Guest..keys platforms.sort_by { |platform| platform == 'other' ? 1 : 0 } end |
#kyc? ⇒ Boolean
37 |
# File 'app/models/concerns/spree_cm_commissioner/kyc_bitwise.rb', line 37 def kyc? = kyc != 0 |
#kyc_fields ⇒ Object
51 52 53 |
# File 'app/models/concerns/spree_cm_commissioner/kyc_bitwise.rb', line 51 def kyc_fields unordered_kyc_fields.sort_by { |item| ORDERED_BIT_FIELDS.index(item) } end |
#kyc_value_enabled?(bit_value) ⇒ Boolean
55 56 57 |
# File 'app/models/concerns/spree_cm_commissioner/kyc_bitwise.rb', line 55 def kyc_value_enabled?(bit_value) kyc & bit_value != 0 end |
#unordered_kyc_fields ⇒ Object
45 46 47 48 49 |
# File 'app/models/concerns/spree_cm_commissioner/kyc_bitwise.rb', line 45 def unordered_kyc_fields BIT_FIELDS.filter_map do |field, bit_value| field if kyc & bit_value != 0 end end |