Class: AdminData::Config

Inherits:
Object
  • Object
show all
Defined in:
lib/admin_data/settings.rb

Class Method Summary collapse

Class Method Details

.initialize_defaultsObject



36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
# File 'lib/admin_data/settings.rb', line 36

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     => nil, 

    :is_allowed_to_update_klass   => 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

  }
end

.set=(input = {}) ⇒ Object



5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
# File 'lib/admin_data/settings.rb', line 5

def self.set=(input = {})
  valid_keys =
  %w(
  adapter_name
  find_conditions
  plugin_dir
  will_paginate_per_page
  
  is_allowed_to_view
  is_allowed_to_view_klass
  is_allowed_to_update
  is_allowed_to_update_klass

  is_allowed_to_view_feed
  feed_authentication_user_id
  feed_authentication_password
  column_settings
  columns_order
  use_google_hosting_for_jquery
  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)

end