Module: Swipecardable

Included in:
User
Defined in:
app/models/swipecardable.rb

Overview

rubocop:todo Style/Documentation

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.included(base) ⇒ Object


17
18
19
20
21
22
23
24
25
26
27
28
29
# File 'app/models/swipecardable.rb', line 17

def self.included(base)
  base.class_eval do
    def self.encrypt_swipecard_code(code)
      User.encrypt(code, nil)
    end

    # won't work, because of the salt.
    scope :with_swipecard_code,
          lambda { |*swipecard_codes|
            where(encrypted_swipecard_code: swipecard_codes.flatten.map { |sw| encrypt_swipecard_code(sw) })
          }
  end
end

Instance Method Details

#compare_swipecard_code(code) ⇒ Object


13
14
15
# File 'app/models/swipecardable.rb', line 13

def compare_swipecard_code(code)
  User.encrypt_swipecard_code(code) == encrypted_swipecard_code
end

#swipecard_codeObject


7
# File 'app/models/swipecardable.rb', line 7

def swipecard_code; end

#swipecard_code=(code) ⇒ Object


3
4
5
# File 'app/models/swipecardable.rb', line 3

def swipecard_code=(code)
  self.encrypted_swipecard_code = User.encrypt_swipecard_code(code)
end

#swipecard_code?Boolean

Returns:

  • (Boolean)

9
10
11
# File 'app/models/swipecardable.rb', line 9

def swipecard_code?
  encrypted_swipecard_code?
end