You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I am considering this in the next release. I feel a little hesitant because it could lead to some production code bugs. For example User.select(:name).first.email will raise an error in ActiveRecord but it would work in ActiveMocker. I considered making it work the same but the complexity is high because the record/object would need to look up to it's owner and see what methods it can emit, but records can be owned by many collections.
# Warning Use method at own risk!
# Method will pass through to the next chained method. The attributes not selected will be available and ActiveRecord
# would raise 'missing attribute' error, while ActiveMocker will not.
#
# User.select(:name, :email) => User
#
def self.select(*args)
self
end
The text was updated successfully, but these errors were encountered:
After thinking about this I am not going to continue with this approach. I am going to have it copy the collection and add a Singleton method to limit what attributes that can be accessed.
I am considering this in the next release. I feel a little hesitant because it could lead to some production code bugs. For example
User.select(:name).first.email
will raise an error in ActiveRecord but it would work in ActiveMocker. I considered making it work the same but the complexity is high because the record/object would need to look up to it's owner and see what methods it can emit, but records can be owned by many collections.The text was updated successfully, but these errors were encountered: