Sha256: 93646b75fed03ed1f08ec1c272a674f7f46455aa2ae5ed3f1c4edf6e86fe8a05

Contents?: true

Size: 1.45 KB

Versions: 1

Compression:

Stored size: 1.45 KB

Contents

module Hancock
  module Model
    extend ActiveSupport::Concern
    included do
      Hancock.register_model(self)

      if Hancock.mongoid?
        include Mongoid::Document
        include Mongoid::Timestamps::Short

        if Hancock.config.localize
          include Hancock::ModelLocalizeable
        end

        _collection_name = collection_name.to_s
        if _collection_name =~ /^hancock_/
          enjoy_collection_name = _collection_name.sub(/^hancock_/, 'enjoy_')
          if Mongoid.client('default').collections.map(&:name).include?(enjoy_collection_name)
            modules = []
            self.name.sub("Hancock", "Enjoy").split("::").each do |mod|
              modules << mod
              eval("::#{modules.join("::")} ||= #{modules.join("::").sub("Enjoy", "Hancock")}")
            end
            store_in collection: enjoy_collection_name
          end
        end

        def self.goto_hancock
        end
      end

      include ActiveModel::ForbiddenAttributesProtection
      include Hancock::BooleanField
      include Hancock::SortField

      if Hancock.mongoid? and defined?(RailsAdminComments)
        include RailsAdminComments::Commentable
        include RailsAdminComments::ModelCommentable
      end

      if Hancock.mongoid?
        if defined?(TrackablePatch)
          include TrackablePatch
        elsif defined?(Trackable)
          include Trackable
        end
      end

      include Hancock::RailsAdminPatch
    end

  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
hancock_cms-1.0.0 lib/hancock/model.rb