6772312ea7
The primary license of the project is changing to: AGPL-3.0-or-later WITH Web-Template-Output-Additional-Permission-3.0-or-later with some specific files to be licensed under the one of two licenses: CC0-1.0 LGPL-3.0-or-later This commit is one of the many steps to relicense the entire codebase. Documentation granting permission for this relicensing (from all past contributors who hold copyrights) is on file with Software Freedom Conservancy, Inc.
50 lines
798 B
Ruby
50 lines
798 B
Ruby
# License: AGPL-3.0-or-later WITH Web-Template-Output-Additional-Permission-3.0-or-later
|
|
module GetData
|
|
|
|
def self.chain(obj, *methods)
|
|
methods.each do |m|
|
|
if m.is_a?(Array)
|
|
params = m[1..-1]
|
|
m = m[0]
|
|
end
|
|
|
|
if obj != nil && obj.respond_to?(m)
|
|
obj = obj.send(m, *params)
|
|
elsif obj.respond_to?(:has_key?) && obj.has_key?(m)
|
|
obj = obj[m]
|
|
else
|
|
return nil
|
|
end
|
|
end
|
|
return obj
|
|
end
|
|
|
|
def self.hash(h, *keys)
|
|
keys.each do |k|
|
|
if h.has_key?(k)
|
|
h = h[k]
|
|
else
|
|
return nil
|
|
end
|
|
end
|
|
return h
|
|
end
|
|
|
|
def self.obj(obj, *methods)
|
|
methods.each do |m|
|
|
if m.is_a?(Array)
|
|
params = m[1..-1]
|
|
m = m[0]
|
|
end
|
|
|
|
if obj != nil && obj.respond_to?(m)
|
|
obj = obj.send(m, *params)
|
|
else
|
|
return nil
|
|
end
|
|
end
|
|
return obj
|
|
end
|
|
|
|
end
|
|
|