Module: ActiveRecord::IdRegions
- Extended by:
- ActiveSupport::Concern
- Defined in:
- lib/active_record/id_regions/version.rb,
lib/active_record/id_regions/migration.rb,
lib/active_record/id_regions.rb
Defined Under Namespace
Modules: ClassMethods, Migration
Constant Summary
collapse
- VERSION =
"0.4.0".freeze
- DEFAULT_RAILS_SEQUENCE_FACTOR =
1_000_000_000_000
- COMPRESSED_ID_SEPARATOR =
'r'.freeze
- CID_OR_ID_MATCHER =
"\\d+?(#{COMPRESSED_ID_SEPARATOR}\\d+)?".freeze
- RE_COMPRESSED_ID =
/^(\d+)#{COMPRESSED_ID_SEPARATOR}(\d+)$/
Instance Method Summary
collapse
Instance Method Details
#compressed_id ⇒ Object
157
158
159
|
# File 'lib/active_record/id_regions.rb', line 157
def compressed_id
self.class.compress_id(id)
end
|
#in_current_region? ⇒ Boolean
148
149
150
|
# File 'lib/active_record/id_regions.rb', line 148
def in_current_region?
region_number == my_region_number
end
|
#my_region_number ⇒ Object
144
145
146
|
# File 'lib/active_record/id_regions.rb', line 144
def my_region_number
self.class.my_region_number
end
|
#region_number ⇒ Object
Also known as:
region_id
152
153
154
|
# File 'lib/active_record/id_regions.rb', line 152
def region_number
id ? (id / self.class.rails_sequence_factor) : my_region_number
end
|
#split_id ⇒ Object
161
162
163
|
# File 'lib/active_record/id_regions.rb', line 161
def split_id
self.class.split_id(id)
end
|