Reorganize module options#50
Conversation
25a1215 to
6f5ef60
Compare
2e02538 to
85e4bca
Compare
|
This change adds extracts hard-coded dependencies in the Two new configuration options can be used to do this: Mobility.option_modules
#=> {
# :cache => Mobility::Backend::Cache,
# :dirty => Mobility::Backend::Dirty,
# :fallbacks => Mobility::Backend::Fallbacks,
# :presence => Mobility::Backend::Presence,
# :default => Mobility::Backend::Default,
# :fallthrough_accessors => Mobility::FallthroughAccessors,
# :locale_accessors => Mobility::LocaleAccessors
# }This is a hash of option keys and constants (classes or modules). The only requirement of the classes used as hash values is that they have a singleton method This hash is iterated over here when initializing an Mobility.default_options
#=> {:cache=>true, :dirty=>false, :fallbacks=>nil, :presence=>true, :default=>nil}The other configuration option is |
... because we should avoid explicit reference to module option keys in modules.
Since Attributes is now independent of its option modules, we should separate the specs as well.
|
Thank you for creating these detailed pull requests, and elaborating your thoughts here! Even though it might feel like no-one is reading these, I for one am grateful to be able to follow along how this gem evolves, and how you think through these changes. 🙇 |
|
Thanks! That's great to hear. I was mainly doing these PRs as mental notes to myself, with the idea that anybody who was interested could follow along, but very glad to hear that they are useful to you and others. Really appreciate that you took the time to express that here 😄 |
Currently there is a lot of hard-coded dependencies between options-setting in
the
Mobility::Attributesclass and the various backend modules (cache,fallbacks, etc.), whereas these should really be independent.
I'm going to try to restructure things so that modules can be defined in such a
way that
Mobility::Attributesdoes not need to explicitly know anything aboutthem when including them from options.