Skip to content

Commit 73bbb9a

Browse files
committed
update
1 parent 30104d7 commit 73bbb9a

2 files changed

Lines changed: 38 additions & 1 deletion

File tree

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
class Sequel::Dataset
2+
def self.===(obj) = obj.is_a?(DProxy) || super
3+
end
4+
5+
class DProxy
6+
def initialize(dataset, model, path = [], &block)
7+
@model, @dataset, @final, @path = model, dataset, block, path
8+
end
9+
10+
def indent(str) = puts "\t" * @path.size + str
11+
def method_missing(name, *args, **kwargs, &block)
12+
all_args = [*args, **kwargs, block:].reject(&:nil?)
13+
# indent "DProxy::#{@model} #{name}(#{all_args}) => IN" unless QUIET
14+
15+
response = if @final && name.to_sym == :all
16+
@final.call self, *all_args
17+
else
18+
@dataset.send(name, *args, **kwargs, &block)
19+
end
20+
# indent "DProxy::#{@model} #{name}(#{all_args}) OUT => #{response.inspect}" unless QUIET
21+
wrap?(response) ? self.class.new(response, @model, @path + [name => all_args, prev: self], &@final) : response
22+
end
23+
24+
def wrap?(r) = r.is_a?(Sequel::Dataset::PlaceholderLiteralizer) || r.is_a?(Sequel::Dataset)
25+
26+
def respond_to_missing?(method_name, include_private = false)
27+
@dataset.respond_to?(method_name, include_private)
28+
end
29+
30+
alias_method :_clone, :clone
31+
32+
def clone( *args, **kwargs, &block)
33+
method_missing(:clone, *args, **kwargs, &block)
34+
end
35+
end
36+
37+

lib/stack-service-base/version.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
module StackServiceBase
2-
VERSION = '0.0.73'
2+
VERSION = '0.0.74'
33
end

0 commit comments

Comments
 (0)