Module: LucaRecord::IO
Overview
IO
Read / Write hash data with id and/or date. Manage both database & historical records.
Defined Under Namespace
Modules: ClassMethods
Class Method Summary collapse
-
.included(klass) ⇒ Object
:nodoc:.
Instance Method Summary collapse
-
#where(**query) ⇒ Object
Used @date for searching current settings query can be nested hash for other than ‘val’.
Methods included from LucaSupport::Code
decimalize, decode_date, decode_id, decode_month, decode_term, decode_txid, delimit_num, encode_date, encode_dirname, encode_month, encode_term, encode_txid, has_status?, issue_random_id, keys_stringify, match_score, parse_current, readable, take_current, take_history, to_ngram
Class Method Details
.included(klass) ⇒ Object
:nodoc:
20 21 22 |
# File 'lib/luca_record/io.rb', line 20 def self.included(klass) # :nodoc: klass.extend ClassMethods end |
Instance Method Details
#where(**query) ⇒ Object
Used @date for searching current settings query can be nested hash for other than ‘val’
where(contract_status: 'active')
where(graded: {rank: 5})
559 560 561 562 563 564 565 566 567 568 569 570 571 572 |
# File 'lib/luca_record/io.rb', line 559 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 |