Skip to content

Conversation

@WorstOfAny
Copy link

Want to have methods that will filter dataset by enum values

@WorstOfAny WorstOfAny force-pushed the add_dataset_filter_methods branch 5 times, most recently from e688bd3 to bd50baa Compare May 18, 2020 20:03
@AlexWayfer
Copy link
Owner

I want a configuration option for this, like for predicate_methods, with false default. Can you make it please?

@AlexWayfer
Copy link
Owner

Friendly ping @WorstOfAny

@AlexWayfer
Copy link
Owner

@WorstOfAny another friendly reminder.

@WorstOfAny WorstOfAny force-pushed the add_dataset_filter_methods branch 8 times, most recently from 63787ec to 5342a93 Compare July 20, 2020 00:33
@WorstOfAny
Copy link
Author

@AlexWayfer sorry for delay. I have added the option you want.

I havent seen 'test container' checks that failed before. Tip me how to fix it pls.

@WorstOfAny WorstOfAny force-pushed the add_dataset_filter_methods branch from 5342a93 to 6227605 Compare July 20, 2020 00:53
@AlexWayfer
Copy link
Owner

@AlexWayfer sorry for delay.

No problem.

I have added the option you want.

Thank you.

I havent seen 'test container' checks that failed before. Tip me how to fix it pls.

It's not your fault. As you can see, for example, here tests are passed, but there is a report to Codecov which failed.

We have many issues with Codecov in these latter days, this one is like codecov/codecov-ruby#69 (comment)

I'll try to fix it separately.

Copy link
Owner

@AlexWayfer AlexWayfer left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please, add documentation into README.

@AlexWayfer
Copy link
Owner

I havent seen 'test container' checks that failed before. Tip me how to fix it pls.

It's not your fault. As you can see, for example, here tests are passed, but there is a report to Codecov which failed.

We have many issues with Codecov in these latter days, this one is like codecov/codecov-ruby#69 (comment)

I'll try to fix it separately.

Should be fixed in #35. Please, rebase the branch to master.

@AlexWayfer
Copy link
Owner

@WorstOfAny friendly reminder.

@AlexWayfer
Copy link
Owner

@WorstOfAny another friendly reminder, sorry. 🙈

@WorstOfAny WorstOfAny force-pushed the add_dataset_filter_methods branch 4 times, most recently from aa328d9 to c974218 Compare September 21, 2020 17:25
@WorstOfAny
Copy link
Author

Please, add documentation into README.

Added

@WorstOfAny WorstOfAny force-pushed the add_dataset_filter_methods branch from c974218 to 0809727 Compare September 21, 2020 17:58
Copy link
Owner

@AlexWayfer AlexWayfer left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good with small notes. Also, please, remember about our discussion about redefining methods.

@AlexWayfer
Copy link
Owner

I think I'll drop Ruby 2.4 in master (about CI fail).

@WorstOfAny WorstOfAny force-pushed the add_dataset_filter_methods branch 2 times, most recently from f3fbbc3 to a2039b5 Compare September 22, 2020 20:23
@AlexWayfer
Copy link
Owner

I think I'll drop Ruby 2.4 in master (about CI fail).

Done.

@AlexWayfer
Copy link
Owner

Another friendly reminder.

@AlexWayfer
Copy link
Owner

Yet another friendly reminder (almost 2 months since the last update).

@AlexWayfer
Copy link
Owner

Yet another friendly reminder (almost 2 months since the last update).

Yet another reminder after almost 4 month.

@WorstOfAny WorstOfAny force-pushed the add_dataset_filter_methods branch from a2039b5 to 62ffd96 Compare March 30, 2021 14:30
@WorstOfAny WorstOfAny requested a review from AlexWayfer March 30, 2021 14:35
@WorstOfAny WorstOfAny force-pushed the add_dataset_filter_methods branch from 62ffd96 to a034894 Compare March 30, 2021 14:37
@AlexWayfer
Copy link
Owner

I see conflicting files, can you resolve it or should I do this?

@WorstOfAny WorstOfAny force-pushed the add_dataset_filter_methods branch from a034894 to 2acc579 Compare April 2, 2021 12:14
@WorstOfAny
Copy link
Author

I see conflicting files, can you resolve it or should I do this?

sry, didn't notice this. Resolved

Copy link
Owner

@AlexWayfer AlexWayfer left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you for returning to this PR.

Plugin can define dataset methods for all enum values:

```ruby
Item.plugin :enum_values, filter_methods: true # default is `false`
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

A small naming suggestion, we can discuss it, but this is what I saw:

You're calling them dataset methods, it's actually Dataset's methods, but you named the option filter_methods. A bit confusing, and I see no problem with dataset_methods option: I don't think that there will be other dataset methods, and it's all about enums.

What do you think?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

i can do it, but for me it's like change name of predicate_methods to instance_methods. We can't filter an instance, only collection or dataset, so that's why filter_methods was used

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

i thought that dataset_methods isn't clear enough naming.

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

My response (with agreement and suggestion) somwhy moved below: #26 (comment)

Array(predicate_methods)
def process_enum_values_options
@enum_values_caching =
@enum_values_options.fetch(:caching, @enum_values_caching)
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It fits in single line, as I see.


process_enum_values_option(:filter_methods) do |field, value|
dataset.methods.include?(value.to_sym) &&
warn("WARNING: Redefining method #{value}")
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

  1. Approach with && for condition very unclear, please use if/unless.
  2. I see no reason for parentheses of warn.
  3. It's a pretty good idea to warn, but I suggest to make it even strict: let raise an exception! And see what will happens with users.

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

  1. And there are should be tests for this behavior!

end

process_enum_values_option(:predicate_methods) do |field, value|
define_method("#{value}?", -> { public_send(field) == value })
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
define_method("#{value}?", -> { public_send(field) == value })
define_method("#{value}?") { public_send(field) == value }

But is here a really need to shorten this non-related code?

Comment on lines +109 to +114
### Filter methods

Plugin can define dataset methods for all enum values:

```ruby
Item.plugin :enum_values, filter_methods: true # default is `false`
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

OK, I agree, what about such changes then?

Suggested change
### Filter methods
Plugin can define dataset methods for all enum values:
```ruby
Item.plugin :enum_values, filter_methods: true # default is `false`
### Dataset filter methods
Plugin can define dataset filter methods for all enum values:
```ruby
Item.plugin :enum_values, filter_methods: true # default is `false`

@AlexWayfer
Copy link
Owner

Do you want some help? 🙄

@AlexWayfer
Copy link
Owner

@WorstOfAny 😥

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