Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feedback on adding a pass through select method. #11

Closed
zeisler opened this issue Aug 7, 2014 · 1 comment
Closed

Feedback on adding a pass through select method. #11

zeisler opened this issue Aug 7, 2014 · 1 comment

Comments

@zeisler
Copy link
Owner

zeisler commented Aug 7, 2014

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
@zeisler
Copy link
Owner Author

zeisler commented Aug 19, 2014

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.

@zeisler zeisler closed this as completed Aug 19, 2014
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant