ActiveSupport::Concern support Module#prepend?

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
4 messages Options
Reply | Threaded
Open this post in threaded view
|

ActiveSupport::Concern support Module#prepend?

Brian Cardarella-3
I've monkey patched this behavior into a gem and I was wondering if core would be interested in a PR to add Module#prepend support to ActiveSupport#Concern. I'll add tests of course.

The code is here:

https://github.com/dockyard/easy_auth/blob/master/lib/easy_auth/active_support/concern.rb

My monkey patch work for what I'm trying to do but I suspect a better implementation would actually have @_dependencies be an array of arrays with each set being the module in the first element then :include or :prepend in the send. Then when `append_features` or `prepend_features` iterates over @_dependencies the send element will be used to call the proper inclusion method.

The only wild card is how ClassMethods will get extended. My understanding is that extend will append class methods to the base class. I cannot seem to find a prepend version of extend.

Thoughts?

--
You received this message because you are subscribed to the Google Groups "Ruby on Rails: Core" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
To post to this group, send email to [hidden email].
Visit this group at http://groups.google.com/group/rubyonrails-core?hl=en.
For more options, visit https://groups.google.com/groups/opt_out.
 
 
Reply | Threaded
Open this post in threaded view
|

Re: ActiveSupport::Concern support Module#prepend?

Brian Cardarella-3
Something like this would be a better implementation:

https://gist.github.com/bcardarella/5735987

On Saturday, June 8, 2013 12:44:13 PM UTC-4, Brian Cardarella wrote:
I've monkey patched this behavior into a gem and I was wondering if core would be interested in a PR to add Module#prepend support to ActiveSupport#Concern. I'll add tests of course.

The code is here:


My monkey patch work for what I'm trying to do but I suspect a better implementation would actually have @_dependencies be an array of arrays with each set being the module in the first element then :include or :prepend in the send. Then when `append_features` or `prepend_features` iterates over @_dependencies the send element will be used to call the proper inclusion method.

The only wild card is how ClassMethods will get extended. My understanding is that extend will append class methods to the base class. I cannot seem to find a prepend version of extend.

Thoughts?

--
You received this message because you are subscribed to the Google Groups "Ruby on Rails: Core" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
To post to this group, send email to [hidden email].
Visit this group at http://groups.google.com/group/rubyonrails-core?hl=en.
For more options, visit https://groups.google.com/groups/opt_out.
 
 
Reply | Threaded
Open this post in threaded view
|

Re: ActiveSupport::Concern support Module#prepend?

jonathan-2
Resurrecting a three-year-old thread...

Is there any interest in AS::Concern better supporting prepend?  I would find it very useful.  There seem to be some solid implementation ideas in the quoted message. Did anyone ever submit as a PR? Is it worthwhile to do? I couldn't find any existing github Issues or PR's on this. 

Jonathan

On Saturday, June 8, 2013 at 1:47:40 PM UTC-4, Brian Cardarella wrote:
Something like this would be a better implementation:

<a href="https://gist.github.com/bcardarella/5735987" target="_blank" rel="nofollow" onmousedown="this.href=&#39;https://www.google.com/url?q\75https%3A%2F%2Fgist.github.com%2Fbcardarella%2F5735987\46sa\75D\46sntz\0751\46usg\75AFQjCNF7Ij900uRpb1tyLmygMkBgpz_QNg&#39;;return true;" onclick="this.href=&#39;https://www.google.com/url?q\75https%3A%2F%2Fgist.github.com%2Fbcardarella%2F5735987\46sa\75D\46sntz\0751\46usg\75AFQjCNF7Ij900uRpb1tyLmygMkBgpz_QNg&#39;;return true;">https://gist.github.com/bcardarella/5735987

On Saturday, June 8, 2013 12:44:13 PM UTC-4, Brian Cardarella wrote:
I've monkey patched this behavior into a gem and I was wondering if core would be interested in a PR to add Module#prepend support to ActiveSupport#Concern. I'll add tests of course.

The code is here:

<a href="https://github.com/dockyard/easy_auth/blob/master/lib/easy_auth/active_support/concern.rb" target="_blank" rel="nofollow" onmousedown="this.href=&#39;https://www.google.com/url?q\75https%3A%2F%2Fgithub.com%2Fdockyard%2Feasy_auth%2Fblob%2Fmaster%2Flib%2Feasy_auth%2Factive_support%2Fconcern.rb\46sa\75D\46sntz\0751\46usg\75AFQjCNHniQn4OF9XcU7sA1-XCkBND3y5FQ&#39;;return true;" onclick="this.href=&#39;https://www.google.com/url?q\75https%3A%2F%2Fgithub.com%2Fdockyard%2Feasy_auth%2Fblob%2Fmaster%2Flib%2Feasy_auth%2Factive_support%2Fconcern.rb\46sa\75D\46sntz\0751\46usg\75AFQjCNHniQn4OF9XcU7sA1-XCkBND3y5FQ&#39;;return true;">https://github.com/dockyard/easy_auth/blob/master/lib/easy_auth/active_support/concern.rb

My monkey patch work for what I'm trying to do but I suspect a better implementation would actually have @_dependencies be an array of arrays with each set being the module in the first element then :include or :prepend in the send. Then when `append_features` or `prepend_features` iterates over @_dependencies the send element will be used to call the proper inclusion method.

The only wild card is how ClassMethods will get extended. My understanding is that extend will append class methods to the base class. I cannot seem to find a prepend version of extend.

Thoughts?

--
You received this message because you are subscribed to the Google Groups "Ruby on Rails: Core" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
To post to this group, send email to [hidden email].
Visit this group at https://groups.google.com/group/rubyonrails-core.
For more options, visit https://groups.google.com/d/optout.
Reply | Threaded
Open this post in threaded view
|

Re: ActiveSupport::Concern support Module#prepend?

mark-3
Resurrenting a five-year-old thread...

If the thread is about having a concern, and allow users to include or prepend it.
It works as of now, for me at least.

jona...@friendsoftheweb.com於 2016年4月7日星期四 UTC+9上午3時47分43秒寫道:
Resurrecting a three-year-old thread...

Is there any interest in AS::Concern better supporting prepend?  I would find it very useful.  There seem to be some solid implementation ideas in the quoted message. Did anyone ever submit as a PR? Is it worthwhile to do? I couldn't find any existing github Issues or PR's on this. 

Jonathan

On Saturday, June 8, 2013 at 1:47:40 PM UTC-4, Brian Cardarella wrote:
Something like this would be a better implementation:

<a href="https://gist.github.com/bcardarella/5735987" rel="nofollow" target="_blank" onmousedown="this.href=&#39;https://www.google.com/url?q\x3dhttps%3A%2F%2Fgist.github.com%2Fbcardarella%2F5735987\x26sa\x3dD\x26sntz\x3d1\x26usg\x3dAFQjCNF7Ij900uRpb1tyLmygMkBgpz_QNg&#39;;return true;" onclick="this.href=&#39;https://www.google.com/url?q\x3dhttps%3A%2F%2Fgist.github.com%2Fbcardarella%2F5735987\x26sa\x3dD\x26sntz\x3d1\x26usg\x3dAFQjCNF7Ij900uRpb1tyLmygMkBgpz_QNg&#39;;return true;">https://gist.github.com/bcardarella/5735987

On Saturday, June 8, 2013 12:44:13 PM UTC-4, Brian Cardarella wrote:
I've monkey patched this behavior into a gem and I was wondering if core would be interested in a PR to add Module#prepend support to ActiveSupport#Concern. I'll add tests of course.

The code is here:

<a href="https://github.com/dockyard/easy_auth/blob/master/lib/easy_auth/active_support/concern.rb" rel="nofollow" target="_blank" onmousedown="this.href=&#39;https://www.google.com/url?q\x3dhttps%3A%2F%2Fgithub.com%2Fdockyard%2Feasy_auth%2Fblob%2Fmaster%2Flib%2Feasy_auth%2Factive_support%2Fconcern.rb\x26sa\x3dD\x26sntz\x3d1\x26usg\x3dAFQjCNHniQn4OF9XcU7sA1-XCkBND3y5FQ&#39;;return true;" onclick="this.href=&#39;https://www.google.com/url?q\x3dhttps%3A%2F%2Fgithub.com%2Fdockyard%2Feasy_auth%2Fblob%2Fmaster%2Flib%2Feasy_auth%2Factive_support%2Fconcern.rb\x26sa\x3dD\x26sntz\x3d1\x26usg\x3dAFQjCNHniQn4OF9XcU7sA1-XCkBND3y5FQ&#39;;return true;">https://github.com/dockyard/easy_auth/blob/master/lib/easy_auth/active_support/concern.rb

My monkey patch work for what I'm trying to do but I suspect a better implementation would actually have @_dependencies be an array of arrays with each set being the module in the first element then :include or :prepend in the send. Then when `append_features` or `prepend_features` iterates over @_dependencies the send element will be used to call the proper inclusion method.

The only wild card is how ClassMethods will get extended. My understanding is that extend will append class methods to the base class. I cannot seem to find a prepend version of extend.

Thoughts?

--
You received this message because you are subscribed to the Google Groups "Ruby on Rails: Core" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
To post to this group, send email to [hidden email].
Visit this group at https://groups.google.com/group/rubyonrails-core.
For more options, visit https://groups.google.com/d/optout.