diff options
author | icebaker <113217272+icebaker@users.noreply.github.com> | 2023-11-29 07:53:19 -0300 |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-11-29 07:53:19 -0300 |
commit | 9f79a161905f5af8e331930cc77c7be10703596f (patch) | |
tree | b2ab75665e42de79f22cca82bf03cfc49759f485 /logic/cartridge/fetch.rb | |
parent | e1ab6853262b83f483060961f17bf895989a19c0 (diff) | |
parent | 154aa68caf50a18af5c0dff1d368fc639314e0ba (diff) |
Merge pull request #5 from icebaker/ib-tools
Adding support for Spec 1.0.0: Tools (Functions)
Diffstat (limited to 'logic/cartridge/fetch.rb')
-rw-r--r-- | logic/cartridge/fetch.rb | 24 |
1 files changed, 24 insertions, 0 deletions
diff --git a/logic/cartridge/fetch.rb b/logic/cartridge/fetch.rb new file mode 100644 index 0000000..2335358 --- /dev/null +++ b/logic/cartridge/fetch.rb @@ -0,0 +1,24 @@ +# frozen_string_literal: true + +require_relative 'default' +require_relative '../helpers/hash' + +module NanoBot + module Logic + module Cartridge + module Fetch + def self.cascate(cartridge, paths) + results = paths.map { |path| Helpers::Hash.fetch(cartridge, path) } + result = results.find { |candidate| !candidate.nil? } + return result unless result.nil? + + results = paths.map { |path| Helpers::Hash.fetch(Default.instance.values, path) } + result = results.find { |candidate| !candidate.nil? } + return result unless result.nil? + + nil + end + end + end + end +end |