Sha256: 9c4b0d067398731010a6a4c7ab31302f494a5f018fb8cced04e756151db6f68d

Contents?: true

Size: 986 Bytes

Versions: 23

Compression:

Stored size: 986 Bytes

Contents

module Stringex
  module ActsAsUrl
    module Adapter
      class Mongoid < Base
        def self.load
          ensure_loadable
          orm_class.send :extend, Stringex::ActsAsUrl::ActsAsUrlClassMethods
        end

      private

        def add_new_record_url_owner_conditions
          return if instance.new_record?
          @url_owner_conditions.merge! :id => {'$ne' => instance.id}
        end

        def add_scoped_url_owner_conditions
          [settings.scope_for_url].flatten.compact.each do |scope|
            @url_owner_conditions.merge! scope => instance.send(scope)
          end
        end

        def get_base_url_owner_conditions
          @url_owner_conditions = {settings.url_attribute => /^#{Regexp.escape(base_url)}/}
        end

        def klass_previous_instances(&block)
          klass.all(settings.url_attribute => [nil]).to_a.each(&block)
        end

        def self.orm_class
          ::Mongoid::Document
        end
      end
    end
  end
end

Version data entries

23 entries across 23 versions & 1 rubygems

Version Path
stringex-2.6.1 lib/stringex/acts_as_url/adapter/mongoid.rb
stringex-2.6.0 lib/stringex/acts_as_url/adapter/mongoid.rb
stringex-2.5.2 lib/stringex/acts_as_url/adapter/mongoid.rb
stringex-2.5.1 lib/stringex/acts_as_url/adapter/mongoid.rb
stringex-2.5.0 lib/stringex/acts_as_url/adapter/mongoid.rb
stringex-2.4.2 lib/stringex/acts_as_url/adapter/mongoid.rb
stringex-2.4.1 lib/stringex/acts_as_url/adapter/mongoid.rb
stringex-2.3.0 lib/stringex/acts_as_url/adapter/mongoid.rb
stringex-2.2.2 lib/stringex/acts_as_url/adapter/mongoid.rb
stringex-2.2.1 lib/stringex/acts_as_url/adapter/mongoid.rb
stringex-2.2.0 lib/stringex/acts_as_url/adapter/mongoid.rb
stringex-2.1.2 lib/stringex/acts_as_url/adapter/mongoid.rb
stringex-2.1.1 lib/stringex/acts_as_url/adapter/mongoid.rb
stringex-2.1.0 lib/stringex/acts_as_url/adapter/mongoid.rb
stringex-2.0.11 lib/stringex/acts_as_url/adapter/mongoid.rb
stringex-2.0.10 lib/stringex/acts_as_url/adapter/mongoid.rb
stringex-2.0.9 lib/stringex/acts_as_url/adapter/mongoid.rb
stringex-2.0.8 lib/stringex/acts_as_url/adapter/mongoid.rb
stringex-2.0.7 lib/stringex/acts_as_url/adapter/mongoid.rb
stringex-2.0.6 lib/stringex/acts_as_url/adapter/mongoid.rb