Module: Octopus::Model::ClassMethods
Class Method Summary
collapse
Instance Method Summary
collapse
#clean_table_name, connection_pool_with_octopus, connection_proxy, connection_with_octopus, #hijack_connection, #hijack_initializer, #set_current_shard, should_use_normal_connection?, #using
Class Method Details
.extended(base) ⇒ Object
128
129
130
131
132
|
# File 'lib/octopus/model.rb', line 128
def self.extended(base)
base.class_attribute(:replicated)
base.class_attribute(:sharded)
base.hijack_methods
end
|
Instance Method Details
#hijack_methods ⇒ Object
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
|
# File 'lib/octopus/model.rb', line 142
def hijack_methods
class << self
attr_accessor :custom_octopus_connection
attr_accessor :custom_octopus_table_name
alias_method_chain(:set_table_name, :octopus)
if Octopus.rails32?
def table_name=(value = nil)
self.custom_octopus_table_name = true
super
end
end
end
end
|
#octopus_establish_connection(spec = ENV['DATABASE_URL']) ⇒ Object
163
164
165
166
|
# File 'lib/octopus/model.rb', line 163
def octopus_establish_connection(spec = ENV['DATABASE_URL'])
self.custom_octopus_connection = true if spec
establish_connection(spec)
end
|
#octopus_set_table_name(value = nil) ⇒ Object
168
169
170
171
|
# File 'lib/octopus/model.rb', line 168
def octopus_set_table_name(value = nil)
ActiveSupport::Deprecation.warn "Calling `octopus_set_table_name` is deprecated and will be removed in Octopus 1.0.", caller
set_table_name(value)
end
|
#replicated_model ⇒ Object
134
135
136
|
# File 'lib/octopus/model.rb', line 134
def replicated_model
self.replicated = true
end
|
#set_table_name_with_octopus(value = nil, &block) ⇒ Object
158
159
160
161
|
# File 'lib/octopus/model.rb', line 158
def set_table_name_with_octopus(value = nil, &block)
self.custom_octopus_table_name = true
set_table_name_without_octopus(value, &block)
end
|
#sharded_model ⇒ Object
138
139
140
|
# File 'lib/octopus/model.rb', line 138
def sharded_model
self.sharded = true
end
|