Class: AllSeeingEye

Inherits:
Object
  • Object
show all
Defined in:
lib/all_seeing_eye.rb,
lib/all_seeing_eye/server.rb,
lib/all_seeing_eye/integrations/rails2.rb

Defined Under Namespace

Modules: Integrations Classes: Model, Server

Class Method Summary collapse

Class Method Details

.configurationObject



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
# File 'lib/all_seeing_eye.rb', line 6

def self.configuration
  location = ENV['ALL_SEEING_EYE_CONFIG'] || 'config'
  @@configuration ||= Hash.new
  @@configuration[:all_seeing_eye] ||= YAML::load_file("./#{location}/all_seeing_eye.yml")
  @@configuration[:redis] ||=
  if @@configuration[:all_seeing_eye]['redis'] && @@configuration[:all_seeing_eye]['redis'][AllSeeingEye.environment]
    @@configuration[:all_seeing_eye]['redis'][AllSeeingEye.environment]
  else
    begin
      YAML::load_file("./#{location}/resque.yml")[AllSeeingEye.environment]
    rescue
      begin
        YAML::load_file("./#{location}/redis.yml")[AllSeeingEye.environment]
      rescue
        'localhost:6379'
      end
    end
  end
  @@configuration[:models] ||= []
  @@configuration[:all_seeing_eye].each do |key, value|
    next if self.default_keys.include?(key) || AllSeeingEye.const_defined?(key.capitalize.to_sym)
    klass = Class.new(AllSeeingEye::Model)
    AllSeeingEye.const_set(key.capitalize.to_sym, klass) 
    @@configuration[:models] << klass
  end
  @@configuration
end

.default_keysObject



34
35
36
# File 'lib/all_seeing_eye.rb', line 34

def self.default_keys
  ['timeout', 'round_to_seconds', 'redis']
end

.environmentObject



2
3
4
# File 'lib/all_seeing_eye.rb', line 2

def self.environment
  ENV['RUBBER_ENV'] || ENV['RAILS_ENV'] || ENV['ALL_SEEING_EYE_ENV'] || 'development'
end

.redisObject



38
39
40
41
42
# File 'lib/all_seeing_eye.rb', line 38

def self.redis
  @@redis ||= Redis.new(:host => AllSeeingEye.configuration[:redis].split(':').first,
                        :port => AllSeeingEye.configuration[:redis].split(':').last,
                        :db => 7)
end