Sha256: 6c90497273b246c3096ad36a0fb6d72b2e882e0f747525d2b6b1a316e2776523
Contents?: true
Size: 728 Bytes
Versions: 1
Compression:
Stored size: 728 Bytes
Contents
module HaveCode module ARCode def self.included(base) base.extend ClassMethods end module ClassMethods def have_code(mod, a, b) write_inheritable_attribute :have_code_cipher, Affine::Cipher.new(mod, a, b) extend OptionalClassMethods include HaveCode::CommonCode::InstanceMethods end end module OptionalClassMethods def find_by_code(code) return nil unless code.is_a? String cipher = read_inheritable_attribute(:have_code_cipher) candidate_id = cipher.decipher code.to_i(36) object = self.find candidate_id return object if object.code == code return nil rescue nil end end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
have-code-0.2.0 | lib/have-code/ar_code.rb |