Sha256: de734352deaf6fb81d2e35e0fc5f71b4bd2f1fa382d4bca817ab86bfb28cf210

Contents?: true

Size: 1.86 KB

Versions: 4

Compression:

Stored size: 1.86 KB

Contents

class AdminData::Config

  cattr_accessor :setting

  def self.set=(input = {})
    valid_keys =
    %w(
    find_conditions
    plugin_dir
    will_paginate_per_page
    is_allowed_to_view
    is_allowed_to_view_feed
    feed_authentication_user_id
    feed_authentication_password
    is_allowed_to_view_klass
    is_allowed_to_update
    is_allowed_to_update_model
    column_settings
    columns_order
    use_google_hosting_for_jquery
    rake_options
    drop_down_for_associations
    ignore_column_limit
    ).collect(&:intern)

    extra_keys = input.keys - valid_keys
    raise "Following options are not supported. #{extra_keys.inspect}" unless extra_keys.empty?

    self.setting ||= {}
    self.setting.merge!(input)

    unless self.setting[:rake_options].blank?
      env = self.setting[:rake_options][:env]
      if env.blank? || env.include?(Rails.env.intern)
        self.setting[:rake_command] = self.setting[:rake_options][:command]
      end
    end

  end

  def self.initialize_defaults
    self.setting = {

      :plugin_dir                   => File.expand_path(File.join(File.dirname(__FILE__), '..', '..')),

      :will_paginate_per_page       => 50,

      :is_allowed_to_view           => lambda {|controller| return true if Rails.env.development? },

      :is_allowed_to_update         => lambda {|controller| return true if Rails.env.development? },

      :is_allowed_to_view_klass     => lambda {|controller| return true  },

      :is_allowed_to_update_model   => lambda {|controller| return true  },

      :find_conditions              => nil,

      :use_google_hosting_for_jquery => true,

      :drop_down_for_associations   => true,

      :ignore_column_limit          => false,

      :columns_order                => nil,

      #TODO fix below
      :adapter_name                 =>   "SQLite" # ActiveRecord::Base.connection.adapter_name

    }
  end

end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
admin_data-1.0.6 lib/admin_data/settings.rb
admin_data-1.0.5 lib/admin_data/settings.rb
admin_data-1.0.4 lib/admin_data/settings.rb
admin_data-1.0.3 lib/admin_data/settings.rb