Remove over meta programming in AR::Relation #26182
Conversation
r? @matthewd (@rails-bot has picked a reviewer for you, use r? to override) |
There are some style violations in the PR. The implementation is good to me, could you fix the violations? |
I don't really like the names |
@matthewd from the other hand I sometimes would want to use |
Well, it will be private API so it can't be official |
|
Ok, I'll gather all variants for you:
Choose wisely. |
@rafaelfranca changed to |
def #{name}_value # def readonly_value | ||
@values[:#{name}] # @values[:readonly] | ||
def #{method_name} # def includes_values | ||
get_value(#{name.inspect}) # get_value(:includes) |
kamipo
Aug 18, 2016
Member
Broken an alignment of comments.
Broken an alignment of comments.
assert_mutability! # assert_mutability! | ||
@values[:#{name}] = value # @values[:readonly] = value | ||
def #{method_name}=(value) # def includes_values=(value) | ||
set_value(#{name.inspect}, value) # set_value(:includes, value) |
kamipo
Aug 18, 2016
Member
ditto.
ditto.
end | ||
|
||
# Sets the relation value with the given name | ||
def set_value(name, value) #:nodoc: |
kamipo
Aug 18, 2016
Member
I am a little curious about #:nodoc:
. get_value
is # :nodoc:
(including a space).
I am a little curious about #:nodoc:
. get_value
is # :nodoc:
(including a space).
another variants: |
if !VALID_UNSCOPING_VALUES.include?(scope) | ||
raise ArgumentError, "Called unscope() with invalid unscoping argument ':#{scope}'. Valid arguments are :#{VALID_UNSCOPING_VALUES.to_a.join(", :")}." | ||
end | ||
set_value(scope, nil) |
kamipo
Aug 18, 2016
Member
Is setting nil
safe for MULTI_VALUE_METHODS
?
Is setting nil
safe for MULTI_VALUE_METHODS
?
bogdan
Aug 18, 2016
•
Author
Contributor
It results in overwriting by default in get on line 929
It results in overwriting by default in get on line 929
kamipo
Aug 18, 2016
Member
I see. Thanks for your explanation!
I see. Thanks for your explanation!
@rafaelfranca @matthewd ready to merge? |
Introduced low level methods #set_value and #get_value for setting query attributes: relation.set_value(:where, {id: 1}) relation.get_value(:includes) Used those internally when working with relation's attributes at the abstract level
This is a partial revert of #26182. There is no reason to change the default value.
Summary
Introduced low level methods #set and #get for setting query attributes:
relation.set(:where, {id: 1})
relation.get(:includes)
Used those internally when working with relation's attributes
at the abstract level