Skip to content

Commit 230de4d

Browse files
committed
Address the rest of offenses
1 parent 1b7b900 commit 230de4d

File tree

2 files changed

+33
-16
lines changed

2 files changed

+33
-16
lines changed

lib/rom/sql/function.rb

Lines changed: 31 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -19,10 +19,10 @@ def frame_limit(value)
1919
when :start then 'UNBOUNDED PRECEDING'
2020
when :end then 'UNBOUNDED FOLLOWING'
2121
else
22-
if value > 0
23-
"#{ value } FOLLOWING"
22+
if value.positive?
23+
"#{value} FOLLOWING"
2424
else
25-
"#{ value.abs } PRECEDING"
25+
"#{value.abs} PRECEDING"
2626
end
2727
end
2828
end
@@ -34,13 +34,14 @@ def frame_limit(value)
3434
WINDOW_FRAMES = Hash.new do |cache, frame|
3535
type = frame.key?(:rows) ? 'ROWS' : 'RANGE'
3636
bounds = frame[:rows] || frame[:range]
37-
cache[frame] = "#{ type } BETWEEN #{ frame_limit(bounds[0]) } AND #{ frame_limit(bounds[1]) }"
37+
cache[frame] =
38+
"#{type} BETWEEN #{frame_limit(bounds[0])} AND #{frame_limit(bounds[1])}"
3839
end
3940

4041
WINDOW_FRAMES[nil] = nil
41-
WINDOW_FRAMES[:all] = WINDOW_FRAMES[rows: [:start, :end]]
42-
WINDOW_FRAMES[:rows] = WINDOW_FRAMES[rows: [:start, :current]]
43-
WINDOW_FRAMES[{ range: :current }] = WINDOW_FRAMES[range: [:current, :current]]
42+
WINDOW_FRAMES[:all] = WINDOW_FRAMES[rows: %i[start end]]
43+
WINDOW_FRAMES[:rows] = WINDOW_FRAMES[rows: %i[start current]]
44+
WINDOW_FRAMES[{ range: :current }] = WINDOW_FRAMES[range: %i[current current]]
4445

4546
# Return a new attribute with an alias
4647
#
@@ -88,10 +89,10 @@ def qualified_projection(table_alias = nil)
8889
end
8990

9091
# @api private
91-
def new(&block)
92+
def new(&)
9293
case func
9394
when ::Sequel::SQL::Function
94-
meta(func: ::Sequel::SQL::Function.new!(func.name, func.args.map(&block), func.opts))
95+
meta(func: ::Sequel::SQL::Function.new!(func.name, func.args.map(&), func.opts))
9596
else
9697
meta(func: func)
9798
end
@@ -125,7 +126,15 @@ def not(other)
125126
#
126127
# @example
127128
# users.select { [id, integer::row_number().over(partition: name, order: id).as(:row_no)] }
128-
# users.select { [id, integer::row_number().over(partition: [first_name, last_name], order: id).as(:row_no)] }
129+
# users.select {
130+
# [
131+
# id,
132+
# integer::row_number().over(
133+
# partition: [first_name, last_name],
134+
# order: id
135+
# ).as(:row_no)
136+
# ]
137+
# }
129138
#
130139
# @example frame variants
131140
# # ROWS BETWEEN 3 PRECEDING AND CURRENT ROW
@@ -167,7 +176,8 @@ def over(partition: nil, order: nil, frame: nil)
167176
# users.select { bool::cast(json_data.get_text('activated')).as(:activated) }
168177
#
169178
# @param [ROM::SQL::Attribute] expr Expression to be cast
170-
# @param [String] db_type Target database type (usually can be inferred from the target data type)
179+
# @param [String] db_type
180+
# Target database type (usually can be inferred from the target data type)
171181
#
172182
# @return [ROM::SQL::Attribute]
173183
#
@@ -214,7 +224,7 @@ def case(mapping)
214224
def filter(condition = Undefined, &block)
215225
if block
216226
conditions = schema.restriction(&block)
217-
conditions = conditions & condition unless condition.equal?(Undefined)
227+
conditions &= condition unless condition.equal?(Undefined)
218228
else
219229
conditions = condition
220230
end
@@ -258,6 +268,15 @@ def func
258268
meta[:func]
259269
end
260270

271+
# @api private
272+
def respond_to_missing?(meth, _include_private = false)
273+
if func
274+
func.respond_to?(meth) || super
275+
else
276+
true
277+
end
278+
end
279+
261280
# @api private
262281
def method_missing(meth, *args)
263282
if func

lib/rom/types/values.rb

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,11 +5,9 @@
55
module ROM
66
module Types
77
module Values
8-
class TreePath < ::Struct.new(:value, :separator)
9-
DEFAULT_SEPARATOR = '.'
10-
8+
class TreePath < ::Struct.new(:value, :separator) # rubocop:disable Style/StructInheritance
119
# @api public
12-
def self.new(value, separator = DEFAULT_SEPARATOR)
10+
def self.new(value, separator = '.')
1311
super
1412
end
1513

0 commit comments

Comments
 (0)