Sha256: 08f07e862e8427f3c64e7172290ff2959c3cf949548d166390b2407e4292b103

Contents?: true

Size: 1.08 KB

Versions: 4

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::Validation
    include RailsAdminSettings::Uploads

    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

4 entries across 4 versions & 1 rubygems

Version Path
rails_admin_settings-0.3.8 app/models/rails_admin_settings/setting.rb
rails_admin_settings-0.3.7 app/models/rails_admin_settings/setting.rb
rails_admin_settings-0.3.6 app/models/rails_admin_settings/setting.rb
rails_admin_settings-0.3.4 app/models/rails_admin_settings/setting.rb