Sha256: 794366daf3e15fea9d9dba820b2f6da75e5ff26c2d76d794dc9935438b07576f

Contents?: true

Size: 1.08 KB

Versions: 5

Compression:

Stored size: 1.08 KB

Contents

# coding: utf-8
module RailsAdminSettings
  class Setting
    include ::Mongoid::Document
    include ::Mongoid::Timestamps::Short

    store_in collection: "rails_admin_settings"

    if Object.const_defined?('Mongoid') && Mongoid.const_defined?('Audit')
      include ::Mongoid::Audit::Trackable
      track_history track_create: true, track_destroy: true
    end

    field :enabled, type: Boolean, default: true
    scope :enabled, where(enabled: true)

    field :type, type: String, default: RailsAdminSettings.types.first

    field :key, type: String
    field :raw, type: String, default: ''

    include RailsAdminSettings::RequireHelpers
    include RailsAdminSettings::Processing
    include RailsAdminSettings::Uploads
    include RailsAdminSettings::Validation


    def disabled?
      !enabled
    end

    def enabled?
      enabled
    end

    index(key: 1)

    if Object.const_defined?('RailsAdmin')
      include RailsAdminSettings::RailsAdminConfig
    else
      puts "[rails_admin_settings] Rails Admin not detected -- put this gem after rails_admin in gemfile"
    end
  end
end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
rails_admin_settings-0.4.3 app/models/rails_admin_settings/setting.rb
rails_admin_settings-0.4.2 app/models/rails_admin_settings/setting.rb
rails_admin_settings-0.4.1 app/models/rails_admin_settings/setting.rb
rails_admin_settings-0.4.0 app/models/rails_admin_settings/setting.rb
rails_admin_settings-0.3.9 app/models/rails_admin_settings/setting.rb