Sha256: 1e7d7b548b8c311a9233a6efe2207eaf92e8d0aad99faaad917a22a433cf2e06

Contents?: true

Size: 769 Bytes

Versions: 1

Compression:

Stored size: 769 Bytes

Contents

require 'active_support/lazy_load_hooks'
require 'switch_point/config'
require 'switch_point/version'

module SwitchPoint
  module ClassMethods
    def configure(&block)
      block.call(config)
    end

    def config
      @config ||= Config.new
    end

    def readonly_all!
      config.keys.each do |name|
        readonly!(name)
      end
    end

    def readonly!(name)
      ProxyRepository.find(name).readonly!
    end

    def writable_all!
      config.keys.each do |name|
        writable!(name)
      end
    end

    def writable!(name)
      ProxyRepository.find(name).writable!
    end
  end
  extend ClassMethods
end

ActiveSupport.on_load(:active_record) do
  require 'switch_point/model'
  ActiveRecord::Base.send(:include, SwitchPoint::Model)
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
switch_point-0.1.0 lib/switch_point.rb