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

The .size of filter associations gives unexpected values #69

Open
ojlyytinen opened this issue Sep 8, 2015 · 0 comments
Open

The .size of filter associations gives unexpected values #69

ojlyytinen opened this issue Sep 8, 2015 · 0 comments

Comments

@ojlyytinen
Copy link

I came across this issue while trying to do something like this with Hydra-works.

class Work < ActiveFedora::Base
  include Hydra::Works::GenericWorkBehavior
end
w = Work.new
w.child_generic_works << Work.new && nil
w.child_generic_works.size

The size will unexpectedly evaluate to zero. If you in any way inspect w.child_generic_works then the size gets updated to what it should be. The "&& nil" is there just so the console doesn't automatically inspect it when testing this in console. In actual code that would not be needed to reproduce the bug.

This doesn't seem to be a Hydra-works specific issue though. You can replace the class with this and the bug is still present

class Work < ActiveFedora::Base
  aggregates :members, predicate: ::RDF::URI.new("http://www.example.com/has_member"), class_name: 'ActiveFedora::Base'
  filters_association :members, as: :child_generic_works, condition: :generic_work?
  def generic_work?
    true
  end
end

The bug also happens if you push the new work to w.members instead of w.child_generic_works. w.members.size however always gives the expected value.

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