module LucaRecord::IO
IO
¶ ↑
Read / Write hash data with id and/or date. Manage both database & historical records.
Public Instance Methods
load_config(path = nil)
click to toggle source
# File lib/luca_record/io.rb, line 428 def load_config(path = nil) path = path.to_s if File.exist?(path) YAML.load_file(path, **{}) else {} end end
where(**query) { |processed| ... }
click to toggle source
Used @date for searching current settings query can be nested hash for other than 'val'
where(contract_status: 'active') where(graded: {rank: 5})
# File lib/luca_record/io.rb, line 413 def where(**query) return enum_for(:where, **query) unless block_given? query.each do |key, val| v = val.respond_to?(:values) ? val.values.first : val label = val.respond_to?(:keys) ? val.keys.first : 'val' self.class.all do |data| next unless data.keys.map(&:to_sym).include?(key) processed = parse_current(data) yield processed if v == processed.dig(key.to_s, label.to_s) end end end