41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
|
# File 'lib/arcane/parameters.rb', line 41
def refine(opts={})
params = self.dup
params.action = opts[:action] || action || params[:action]
params.user = opts[:user] || user
params.object = opts[:object] || object
refinery = Arcane::Finder.new(params.object).refinery.new(params.object, params.user)
args = if params.action.nil?
[]
elsif refinery.respond_to?(params.action)
refinery.public_send(params.action)
elsif refinery.respond_to?(:default)
refinery.default
else
[]
end
root = if refinery.respond_to?(:root)
refinery.root
elsif refinery.class.respond_to?(:root)
refinery.class.root
else
Arcane::Finder.object_name(params.object)
end
return root.present? ? params.require(root.underscore).permit(*args) : params.permit(*args)
end
|