flip icon indicating copy to clipboard operation
flip copied to clipboard

Allow strategy to be called on arbitrary classes

Open jcoyne opened this issue 8 years ago • 2 comments

Prior to this change, it attempt to use the hardcoded Feature class, whether or not it exists.

So, when I attempted to namespace my Feature class I got the following error:

NameError: uninitialized constant Flip::DatabaseStrategy::Feature
/Users/jcoyne/.rbenv/versions/2.3.0/lib/ruby/gems/2.3.0/gems/flip-1.1.0/lib/flip/database_strategy.rb:5:in
`initialize'
/Users/jcoyne/.rbenv/versions/2.3.0/lib/ruby/gems/2.3.0/gems/flip-1.1.0/lib/flip/feature_set.rb:36:in
`new'
/Users/jcoyne/.rbenv/versions/2.3.0/lib/ruby/gems/2.3.0/gems/flip-1.1.0/lib/flip/feature_set.rb:36:in
`add_strategy'
/Users/jcoyne/.rbenv/versions/2.3.0/lib/ruby/gems/2.3.0/gems/flip-1.1.0/lib/flip/declarable.rb:15:in
`strategy'
/Users/jcoyne/workspace/curation_concerns/app/models/curation_concerns/feature.rb:6:in
`<class:Feature>'

jcoyne avatar Aug 19 '16 18:08 jcoyne

@pda Do you have any feedback about this PR?

jcoyne avatar Aug 23 '16 16:08 jcoyne

Ideally I think features should be declared in an initializer, not in a model class, as per https://github.com/pda/flip/issues/1#issuecomment-2809201, and then the model class should be customizable. However that would be a breaking change.

Perhaps this PR is a decent backwards-compatible way to at least escape the hard-coded Feature class though…?

pda avatar Aug 31 '16 00:08 pda