module Protobuf
  module ActiveRecord
    class Railtie < Rails::Railtie
      config.protobuf_active_record = Protobuf::ActiveRecord.config

      ActiveSupport.on_load(:active_record) do
        on_inherit do
          include Protobuf::ActiveRecord::Model if Protobuf::ActiveRecord.config.autoload
        end
      end

      ActiveSupport.on_load(:protobuf_rpc_service) do
        include Protobuf::ActiveRecord::ServiceFilters
      end
    end
  end
end

module Protobuf
  module ActiveRecord
    class Railtie < Rails::Railtie
      config.protobuf_active_record = Protobuf::ActiveRecord.config

      ActiveSupport.on_load(:active_record) do
        on_inherit do
          include Protobuf::ActiveRecord::Model if Protobuf::ActiveRecord.config.autoload
        end
      end

      ActiveSupport.on_load(:protobuf_rpc_service) do
        on_inherit do
          include Protobuf::ActiveRecord::ServiceFilters
        end
      end
    end
  end
end

Include service filters into services on inherit
Include service filters into services on inherit

Filters are only run in the class the are defined in. They are not
inherited. That means we need to inject them into each service that
inherits from PB's RPC::Service class instead.
