Class: ConfigBases

Inherits:
Entities show all
Includes:
Observable
Defined in:
lib/qooxview/helpers/config_base.rb

Instance Attribute Summary

Attributes inherited from Entities

#blocks, #changed, #data, #data_class, #data_field_id, #data_instances, #is_loaded, #keys, #last_id, #loading, #name, #null_allowed, #save_after_create, #storage, #values

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from Entities

delete_all_data, #get_block_fields, #get_data_instance, #get_field_names, #get_non_list_field_names, #get_value, has_entity?, #initialize, is_setup?, load, load_all, #match_by_id, method_missing, #method_missing, needs, reload, #respond_to?, save_all, service, #singular, #value_add, #value_add_, #value_block, #value_date, #value_entity, #value_int, #value_list_drop_, #value_str, #value_time, #whoami

Methods included from StorageHandler

#add_new_storage, #add_value_to_storage, #create, #create_key, #data_update, #delete_all, #delete_id, #field_args, #filter_by, #find, #find_by, #find_key_by, #first, #get_entry, #has_field?, #has_storage?, #last, #load, #match_by, #match_key, #matches_by, #migrate, #new_id, #replace_st, #save, #save_data, #search_all, #search_all_, #search_by, #search_by_all, #set_entry, #update_key

Methods inherited from RPCQooxdooService

add_prime_service, entities, #get_services, inherited, #initialize, migrate_all, needs, #needs_covered, services

Constructor Details

This class inherits a constructor from Entities

Dynamic Method Handling

This class handles dynamic methods through the method_missing method in the class Entities

Class Method Details

.list_functionsObject



87
88
89
90
91
92
93
# File 'lib/qooxview/helpers/config_base.rb', line 87

def self.list_functions
  index = 0
  @@functions.collect { |f|
    index += 1
    [index, f.to_sym]
  }
end

.singletonObject



82
83
84
85
# File 'lib/qooxview/helpers/config_base.rb', line 82

def self.singleton
  first or
      self.create({:functions => [], :locale_force => nil, :welcome_msg => ''})
end

Instance Method Details

#call_changed(action, value, old) ⇒ Object



54
55
56
57
58
# File 'lib/qooxview/helpers/config_base.rb', line 54

def call_changed(action, value, old)
  ConfigBases.singleton.update(action, value, old)
  changed
  notify_observers(action, value, old)
end

#functionsObject



60
61
62
# File 'lib/qooxview/helpers/config_base.rb', line 60

def functions
  @@functions
end

#functions_baseObject



64
65
66
# File 'lib/qooxview/helpers/config_base.rb', line 64

def functions_base
  @@functions_base
end

#functions_conflictObject



68
69
70
# File 'lib/qooxview/helpers/config_base.rb', line 68

def functions_conflict
  @@functions_conflict
end

#init_loadObject



76
77
78
79
80
# File 'lib/qooxview/helpers/config_base.rb', line 76

def init_load
  ConfigBases.load
  ConfigBases.singleton
  ConfigBases.migrate
end

#list_functionsObject



72
73
74
# File 'lib/qooxview/helpers/config_base.rb', line 72

def list_functions
  self.list_functions
end

#migration_1(c) ⇒ Object



36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
# File 'lib/qooxview/helpers/config_base.rb', line 36

def migration_1(c)
  c._debug_lvl = DEBUG_LVL
  c._locale_force = 'fr'
  c._welcome_text = 'Welcome to Profeda'
  # Values for slow, buggy lines. For a good transfer-rate, choose 16x more
  c._block_size = 4096
  c._max_upload_size = 65_536
  c.dputs_logall = '/var/log/gestion/gestion.log'
  c.dputs_logfile = '/var/log/gestion/events.log'
  c.dputs_show_time = %w(min)
  c.dputs_silent = %w(false)
  c.dputs_terminal_width = 160
  c.openprint_simul = %w(false)
  c.openprint_search = '.*'

  dputs(3) { "Migrating out: #{c.inspect}" }
end

#setup_dataObject



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/qooxview/helpers/config_base.rb', line 8

def setup_data
  value_block :wide
  value_list :functions, 'ConfigBases.list_functions'
  value_str :dputs_logfile
  value_str :dputs_logall
  value_text :welcome_text

  value_block :narrow
  value_str :locale_force
  value_str :use_printing
  value_list_drop :openprint_simul, '%w(true false)'
  value_str :openprint_search
  value_int :debug_lvl
  value_list_drop :dputs_show_time, '%w(false min sec)'
  value_list_drop :dputs_silent, '%w(false true)'
  value_int :dputs_terminal_width
  value_int :block_size
  value_int :max_upload_size

  @@functions = []
  @@functions_base = {}
  @@functions_conflict = []

  respond_to? :add_config and add_config

  return true
end