Class: TG::Geometry::Registry
- Inherits:
-
Object
- Object
- TG::Geometry::Registry
- Extended by:
- Forwardable
- Defined in:
- lib/tg/geometry/registry.rb
Constant Summary collapse
- DEFAULT_INDEX_OPTIONS =
{ via: :geojson, strategy: :rtree, predicate: :covers, geometry_index: :ystripes }.freeze
Instance Attribute Summary collapse
-
#index_options ⇒ Object
readonly
Returns the value of attribute index_options.
Class Method Summary collapse
Instance Method Summary collapse
- #index ⇒ Object
-
#initialize(entries: nil, source: nil, **index_options) ⇒ Registry
constructor
A new instance of Registry.
- #loaded? ⇒ Boolean
- #reload! ⇒ Object
Constructor Details
#initialize(entries: nil, source: nil, **index_options) ⇒ Registry
Returns a new instance of Registry.
36 37 38 39 40 41 42 |
# File 'lib/tg/geometry/registry.rb', line 36 def initialize(entries: nil, source: nil, **) @entries = entries @source = source = self.class..merge().freeze @reload_mutex = Mutex.new @index = nil end |
Instance Attribute Details
#index_options ⇒ Object (readonly)
Returns the value of attribute index_options.
31 32 33 |
# File 'lib/tg/geometry/registry.rb', line 31 def end |
Class Method Details
.index_options(**options) ⇒ Object
23 24 25 26 27 28 |
# File 'lib/tg/geometry/registry.rb', line 23 def (**) inherited = superclass.respond_to?(:index_options) ? superclass. : DEFAULT_INDEX_OPTIONS return inherited.merge( || {}).freeze if .empty? = inherited.merge( || {}, ).freeze end |
.source(&block) ⇒ Object
18 19 20 21 |
# File 'lib/tg/geometry/registry.rb', line 18 def source(&block) @source = block if block @source || (superclass.source if superclass.respond_to?(:source)) end |
Instance Method Details
#index ⇒ Object
50 51 52 |
# File 'lib/tg/geometry/registry.rb', line 50 def index @index || raise(TG::Geometry::Error, "registry index is not loaded; call reload! first") end |
#loaded? ⇒ Boolean
54 |
# File 'lib/tg/geometry/registry.rb', line 54 def loaded? = !@index.nil? |
#reload! ⇒ Object
44 45 46 47 48 |
# File 'lib/tg/geometry/registry.rb', line 44 def reload! new_index = TG::Geometry::Index.build(resolve_entries, **) @reload_mutex.synchronize { @index = new_index } new_index end |