Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

SpatialFactoryStore#default API can be hard to grasps #80

Open
BuonOmo opened this issue Oct 16, 2024 · 0 comments
Open

SpatialFactoryStore#default API can be hard to grasps #80

BuonOmo opened this issue Oct 16, 2024 · 0 comments

Comments

@BuonOmo
Copy link
Member

BuonOmo commented Oct 16, 2024

Issue create from this discussion: rgeo/activerecord-postgis-adapter#412 (comment)

The accessor for #default also behaves as a setter:

      def default(attrs = {})
        @default || default_for_attrs(attrs)
      end

This was messing up with the test suite in activerecord-postgis-adapter. Shall we find an API that is less error-prone?

For instance, a user doing:

old_default = spatial_factory_store.default
spatial_factory_store.default = my_mock
# some tests
spatial_factory_store.default = old_default

would actually get a different instance of spatial_factory_store at the beginning and the end (the first one doesn't necessarily have default set, the second one does).

Another issue is this one:

# in initializer
spatial_factory_store.default = some_default

# later in the codebase
factory = spatial_factory_store.default(specific_attributes)
# the `specific_attributes` will not be taken into account
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant