Module: XBar
- Defined in:
- lib/xbar.rb,
lib/xbar/shard.rb,
lib/xbar/mapper.rb,
lib/xbar/version.rb,
lib/xbar/rails2/association.rb,
lib/xbar/rails2/persistence.rb,
lib/xbar/rails3/association.rb,
lib/xbar/rails3/persistence.rb
Defined Under Namespace
Modules: Association, AssociationCollection, HasAndBelongsToManyAssociation, Mapper, Migration, Model, Rails2, Rails3, SingularAssociation
Classes: ConfigError, Logger, Proxy, ScopeProxy, Shard
Constant Summary
collapse
- VERSION =
'0.4.0'
Class Attribute Summary collapse
Class Method Summary
collapse
Class Attribute Details
.debug ⇒ Object
Returns the value of attribute debug.
18
19
20
|
# File 'lib/xbar.rb', line 18
def debug
@debug
end
|
Class Method Details
.collect_stats? ⇒ Boolean
49
50
51
|
# File 'lib/xbar.rb', line 49
def self.collect_stats?
@stats ||= false
end
|
.directory ⇒ Object
Returns the Rails.root_to_s when you are using rails Running the current directory in a generic Ruby process
33
34
35
|
# File 'lib/xbar.rb', line 33
def self.directory
@directory ||= defined?(Rails) ? Rails.root.to_s : Dir.pwd
end
|
.directory=(dir) ⇒ Object
37
38
39
|
# File 'lib/xbar.rb', line 37
def self.directory=(dir)
@directory = dir
end
|
.disable_stats ⇒ Object
45
46
47
|
# File 'lib/xbar.rb', line 45
def self.disable_stats
@stats = false
end
|
.enable_stats ⇒ Object
41
42
43
|
# File 'lib/xbar.rb', line 41
def self.enable_stats
@stats = true
end
|
.environments ⇒ Object
63
64
65
|
# File 'lib/xbar.rb', line 63
def self.environments
@environments || ['production', 'test', 'development']
end
|
.environments=(environments) ⇒ Object
59
60
61
|
# File 'lib/xbar.rb', line 59
def self.environments=(environments)
@environments = environments.map { |element| element.to_s }
end
|
.rails31? ⇒ Boolean
71
72
73
|
# File 'lib/xbar.rb', line 71
def self.rails31?
ActiveRecord::VERSION::MAJOR == 3 && ActiveRecord::VERSION::MINOR >= 1
end
|
.rails32? ⇒ Boolean
75
76
77
|
# File 'lib/xbar.rb', line 75
def self.rails32?
ActiveRecord::VERSION::MAJOR == 3 && ActiveRecord::VERSION::MINOR >= 2
end
|
.rails3? ⇒ Boolean
67
68
69
|
# File 'lib/xbar.rb', line 67
def self.rails3?
ActiveRecord::VERSION::MAJOR == 3
end
|
.rails? ⇒ Boolean
79
80
81
|
# File 'lib/xbar.rb', line 79
def self.rails?
defined?(Rails)
end
|
.rails_env ⇒ Object
There is no corresponding ‘setter’ method because this is not how the Rails environment is set.
23
24
25
|
# File 'lib/xbar.rb', line 23
def self.rails_env
defined?(Rails) ? Rails.env.to_s : nil
end
|
.setup {|_self| ... } ⇒ Object
This is the default way to do XBar Setup
55
56
57
|
# File 'lib/xbar.rb', line 55
def self.setup
yield self
end
|
.shards=(shards) ⇒ Object
83
84
85
|
# File 'lib/xbar.rb', line 83
def self.shards=(shards)
XBar::Mapper.shards = shards
end
|
.using(shard, &block) ⇒ Object
87
88
89
90
91
92
93
94
|
# File 'lib/xbar.rb', line 87
def self.using(shard, &block)
conn = ActiveRecord::Base.connection
if conn.is_a?(XBar::Proxy)
conn.run_queries_on_shard(shard, &block)
else
yield
end
end
|