Sha256: 7c943b921960ea5cae0805970070ab1e0c4a4a92becf5b54e522f2a192f17990
Contents?: true
Size: 836 Bytes
Versions: 2
Compression:
Stored size: 836 Bytes
Contents
# frozen_string_literal: true module SchemaMonkey # The main manager for the monkey patches. Singleton instance # created by SchemaMonkey.monkey class Monkey def initialize @client_map = {} @inserted = nil @inserted_dbm = nil Module.insert ::ActiveRecord::ConnectionAdapters::AbstractAdapter, SchemaMonkey::ActiveRecord::ConnectionAdapters::AbstractAdapter end def register(mod) @client_map[mod] ||= Client.new(mod).tap { |client| client.insert if @inserted client.insert(dbm: @inserted_dbm) if @inserted_dbm } end def insert(dbm: nil) insert if dbm and not @inserted # first do all non-dbm-specific insertions @client_map.values.each { |it| it.insert(dbm: dbm) } @inserted = true @inserted_dbm = dbm if dbm end end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
schema_monkey-3.0.2 | lib/schema_monkey/monkey.rb |
schema_monkey-3.0.2.beta.1 | lib/schema_monkey/monkey.rb |