Skip to content

Commit

Permalink
Ensure that flipper itself has the extensions for active record
Browse files Browse the repository at this point in the history
  • Loading branch information
jnunemaker committed Dec 9, 2023
1 parent acab7e4 commit 9021aae
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 3 deletions.
15 changes: 15 additions & 0 deletions examples/cloud/checks.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@

# Usage (from the repo root):
# env FLIPPER_CLOUD_TOKEN=<token> bundle exec ruby examples/cloud/basic.rb

require_relative "./cloud_setup"
require 'bundler/setup'
require 'flipper/cloud'

Flipper.enabled?(:audit_log)
Flipper.enabled?(:audit_log)
Flipper.enabled?(:redesign)
Flipper.enabled?(:search)
Flipper.enabled?(:search_pro)
Flipper.enabled?(:stats)
Flipper.enabled?(:subscriptions)
9 changes: 8 additions & 1 deletion flipper-active_record.gemspec
Original file line number Diff line number Diff line change
@@ -1,9 +1,16 @@
# -*- encoding: utf-8 -*-
require File.expand_path('../lib/flipper/version', __FILE__)
require File.expand_path('../lib/flipper/metadata', __FILE__)
require "set"

# Files that should exist in main flipper gem.
main_flipper_active_record_files = Set[
"lib/flipper/model/active_record.rb",
"spec/flipper/model/active_record_spec.rb",
]

flipper_active_record_files = lambda do |file|
file =~ /active_record/
file =~ /active_record/ && !main_flipper_active_record_files.include?(file)
end

Gem::Specification.new do |gem|
Expand Down
3 changes: 1 addition & 2 deletions lib/flipper/engine.rb
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,8 @@ class Engine < Rails::Engine
end

initializer "flipper.properties" do
require "flipper/model/active_record"

ActiveSupport.on_load(:active_record) do
require "flipper/model/active_record"
ActiveRecord::Base.include Flipper::Model::ActiveRecord
end
end
Expand Down

0 comments on commit 9021aae

Please sign in to comment.