Class: BigIndex::Repository
- Inherits:
-
Object
- Object
- BigIndex::Repository
- Includes:
- Assertions
- Defined in:
- lib/big_index/repository.rb
Instance Attribute Summary collapse
-
#name ⇒ Object
readonly
Returns the value of attribute name.
Class Method Summary collapse
-
.adapters ⇒ Adapter
The adapters registered for this repository.
-
.clear_adapters ⇒ Object
TODO: Make sure this isn’t dangerous.
- .context ⇒ Object
- .default_name ⇒ Object
- .default_name=(name) ⇒ Object
Instance Method Summary collapse
- #adapter ⇒ Object
- #eql?(other) ⇒ Boolean (also: #==)
-
#scope ⇒ Object
TODO: spec this.
- #to_s ⇒ Object
Methods included from Assertions
Instance Attribute Details
#name ⇒ Object (readonly)
Returns the value of attribute name.
32 33 34 |
# File 'lib/big_index/repository.rb', line 32 def name @name end |
Class Method Details
.adapters ⇒ Adapter
Returns the adapters registered for this repository.
11 12 13 |
# File 'lib/big_index/repository.rb', line 11 def self.adapters @adapters end |
.clear_adapters ⇒ Object
TODO: Make sure this isn’t dangerous
28 29 30 |
# File 'lib/big_index/repository.rb', line 28 def self.clear_adapters @adapters = {} end |
.context ⇒ Object
15 16 17 |
# File 'lib/big_index/repository.rb', line 15 def self.context Thread.current[:bigindex_repository_contexts] ||= [] end |
.default_name ⇒ Object
19 20 21 |
# File 'lib/big_index/repository.rb', line 19 def self.default_name @default_name ||= :default end |
.default_name=(name) ⇒ Object
23 24 25 |
# File 'lib/big_index/repository.rb', line 23 def self.default_name=(name) @default_name = name end |
Instance Method Details
#adapter ⇒ Object
34 35 36 37 38 39 40 41 42 43 |
# File 'lib/big_index/repository.rb', line 34 def adapter # Make adapter instantiation lazy so we can defer repository setup until it's actually # needed. Do not remove this code. @adapter ||= begin raise ArgumentError, "Adapter not set: #{@name}. Did you forget to setup?" \ unless self.class.adapters.has_key?(@name) self.class.adapters[@name] end end |
#eql?(other) ⇒ Boolean Also known as: ==
56 57 58 59 |
# File 'lib/big_index/repository.rb', line 56 def eql?(other) return true if super name == other.name end |
#scope ⇒ Object
TODO: spec this
46 47 48 49 50 51 52 53 54 |
# File 'lib/big_index/repository.rb', line 46 def scope Repository.context << self begin return yield(self) ensure Repository.context.pop end end |
#to_s ⇒ Object
63 64 65 |
# File 'lib/big_index/repository.rb', line 63 def to_s "#<BigIndex::Repository:#{@name}>" end |