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

Allow strategy to be called on arbitrary classes #48

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

jcoyne
Copy link
Contributor

@jcoyne jcoyne commented Aug 19, 2016

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>'

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
Copy link
Contributor Author

jcoyne commented Aug 23, 2016

@pda Do you have any feedback about this PR?

@pda
Copy link
Owner

pda commented Aug 31, 2016

Ideally I think features should be declared in an initializer, not in a model class, as per #1 (comment), 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…?

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

Successfully merging this pull request may close these issues.

2 participants