clowne-rb / clowne

A flexible gem for cloning models
https://clowne.evilmartians.io
MIT License
316 stars 18 forks source link

If/Unless modifiers #14

Open palkan opened 6 years ago

palkan commented 6 years ago
class StageCloner < Clowne::Cloner
  # Symbol support (method is called on the source)
  include_association :comments, if: :published?

  # Block support
  include_association :votes, if: ->(source, record, params) { params[:need_votes] }
end
ssnickolay commented 6 years ago

Is this modifier will be for all declarations (finalize, nullify, exclude_association...)?

palkan commented 6 years ago

Yep, I think it should be a part of abstract Base declaration (which we don't have now).

Frankly speaking, I'm not sure about the usefulness of this feature. Haven't had a case for it yet.

ssnickolay commented 6 years ago

Frankly speaking, I'm not sure about the usefulness of this feature. Haven't had a case for it yet.

But we can add flexibility in the configuration with this enhancement) And more complexity, of course...