Nathan Broadbent
2013-Aug-20 03:10 UTC
Suggestion for #store_accessor to also define query and _was methods
Dear Rails Core mailing list, I would like to propose some additions to the #store_accessor method, so that also defines query and _was methods. Example usage: class User < ActiveRecord::Base store :settings, accessors: [ :color, :homepage ], coder: JSON end u = User.create(color: ''black'', homepage: ''37signals.com'') u.color? # => true u.color = ''white'' u.color_was # => "black" I can submit a PR if you support the change. Thanks, Nathan -- 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 rubyonrails-core+unsubscribe@googlegroups.com. To post to this group, send email to rubyonrails-core@googlegroups.com. Visit this group at http://groups.google.com/group/rubyonrails-core. For more options, visit https://groups.google.com/groups/opt_out.
Mohamed Wael Khobalatte
2013-Aug-20 03:30 UTC
Re: Suggestion for #store_accessor to also define query and _was methods
Do we have enough use cases to support adding the _was method? On Mon, Aug 19, 2013 at 11:10 PM, Nathan Broadbent <nathan.f77@gmail.com>wrote:> Dear Rails Core mailing list, > > I would like to propose some additions to the #store_accessor method, so > that also defines query and _was methods. > > Example usage: > > class User < ActiveRecord::Base > store :settings, accessors: [ :color, :homepage ], coder: JSON > end > > u = User.create(color: ''black'', homepage: ''37signals.com'') > > > > u.color? # => true > > u.color = ''white'' > u.color_was # => "black" > > > I can submit a PR if you support the change. > > > Thanks, > Nathan > > -- > 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 rubyonrails-core+unsubscribe@googlegroups.com. > To post to this group, send email to rubyonrails-core@googlegroups.com. > Visit this group at http://groups.google.com/group/rubyonrails-core. > For more options, visit https://groups.google.com/groups/opt_out. >-- Mohamed Wael Khobalatte -- 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 rubyonrails-core+unsubscribe@googlegroups.com. To post to this group, send email to rubyonrails-core@googlegroups.com. Visit this group at http://groups.google.com/group/rubyonrails-core. For more options, visit https://groups.google.com/groups/opt_out.
Jonathan Lozinski
2013-Aug-20 06:21 UTC
Re: Suggestion for #store_accessor to also define query and _was methods
I don''t think we need to have specific cases to justify _was. The purpose, AFAIK, with the store accessors is to be transparent about whether they''re full columns or not. For this reason, they should accommodate the same methods, such as changed? and the _was methods to accurately reflect the same API that attributes have. On 20 August 2013 04:30, Mohamed Wael Khobalatte <wael.khobalatte@gmail.com>wrote:> Do we have enough use cases to support adding the _was method? > > > On Mon, Aug 19, 2013 at 11:10 PM, Nathan Broadbent <nathan.f77@gmail.com>wrote: > >> Dear Rails Core mailing list, >> >> I would like to propose some additions to the #store_accessor method, so >> that also defines query and _was methods. >> >> Example usage: >> >> class User < ActiveRecord::Base >> store :settings, accessors: [ :color, :homepage ], coder: JSON >> end >> >> u = User.create(color: ''black'', homepage: ''37signals.com'') >> >> >> >> u.color? # => true >> >> u.color = ''white'' >> u.color_was # => "black" >> >> >> I can submit a PR if you support the change. >> >> >> Thanks, >> Nathan >> >> -- >> 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 rubyonrails-core+unsubscribe@googlegroups.com. >> To post to this group, send email to rubyonrails-core@googlegroups.com. >> Visit this group at http://groups.google.com/group/rubyonrails-core. >> For more options, visit https://groups.google.com/groups/opt_out. >> > > > > -- > Mohamed Wael Khobalatte > > -- > 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 rubyonrails-core+unsubscribe@googlegroups.com. > To post to this group, send email to rubyonrails-core@googlegroups.com. > Visit this group at http://groups.google.com/group/rubyonrails-core. > For more options, visit https://groups.google.com/groups/opt_out. >-- 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 rubyonrails-core+unsubscribe@googlegroups.com. To post to this group, send email to rubyonrails-core@googlegroups.com. Visit this group at http://groups.google.com/group/rubyonrails-core. For more options, visit https://groups.google.com/groups/opt_out.