summaryrefslogtreecommitdiff
path: root/vendor/gems/attr_encrypted/lib/attr_encrypted/adapters/data_mapper.rb
blob: 03fb5caa45786d3ed0abb652325d003298ef5804 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
# frozen_string_literal: true

if defined?(DataMapper)
  module AttrEncrypted
    module Adapters
      module DataMapper
        def self.extended(base) # :nodoc:
          class << base
            alias_method :included_without_attr_encrypted, :included
            alias_method :included, :included_with_attr_encrypted
          end
        end

        def included_with_attr_encrypted(base)
          included_without_attr_encrypted(base)
          base.extend AttrEncrypted
          base.attr_encrypted_options[:encode] = true
        end
      end
    end
  end

  DataMapper::Resource.extend AttrEncrypted::Adapters::DataMapper
end