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

GenericWorks should have a .generic_file_ids= setter method #208

Closed
flyingzumwalt opened this issue Sep 8, 2015 · 5 comments
Closed

GenericWorks should have a .generic_file_ids= setter method #208

flyingzumwalt opened this issue Sep 8, 2015 · 5 comments

Comments

@flyingzumwalt
Copy link
Member

I think this translates into a feature request for AF::Aggregation, but the request only makes sense with an example. This is the example.

Use case: changing the order of generic_files within a generic_work
Currently I have to

page_ids = book.generic_file_ids
# {... rearrange page_ids ...}
book.member_ids = page_ids

I get an error if I try to call book.generic_file_ids = page_ids, even though that's where I got the ids.

Note that generic_file_ids is a filtered subset of member_ids, so the code sample here actually risks accidentally removing other members from book.members.

Of course, I could always use member_ids for both getter and setter but that violates the whole reason for having the generic_file_ids method in the first place.

@flyingzumwalt
Copy link
Member Author

@jcoyne
Copy link
Member

jcoyne commented Sep 9, 2015

Keep in mind that the ids setter isn't going to get you much. It'll still have to do a find on each of the ids so that it can run the type_validator on each member.

@flyingzumwalt
Copy link
Member Author

Ah. So maybe it's a moot point for tomorrow's work. I was hoping to avoid loading the objects before saving the new order.

@flyingzumwalt
Copy link
Member Author

My use case is for reordering page images within books that sometimes have
hundreds of pages. Loading all of the member objects is not an option.

On Tuesday, September 8, 2015, Justin Coyne notifications@github.com
wrote:

Keep in mind that the ids setter isn't going to get you much. It'll still
have to do a find on each of the ids so that it can run the type_validator
on each member.


Reply to this email directly or view it on GitHub
#208 (comment)
.

@jcoyne
Copy link
Member

jcoyne commented Sep 9, 2015

Yeah, I think you want to make a special function for that. Maybe AggregationProxy#swap(i, j)

@jcoyne jcoyne closed this as completed Sep 9, 2015
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

2 participants