Sha256: 968c56612f4b4280d91476c381371ecde4678861d2f2bc77a1f052037fe0b76a
Contents?: true
Size: 1.43 KB
Versions: 2
Compression:
Stored size: 1.43 KB
Contents
module Base @@evaluate = false def evaluate(value = true) @@evaluate = value self end private def evaluate? value = @@evaluate @@evaluate = false value end def append?(order) order.to_s == 'append' end # rubocop:disable Lint/RescueException, Security/Eval def metaform(value) value.nil? ? value : eval(value) rescue Exception value end # rubocop:enable Lint/RescueException, Security/Eval # rubocop:disable Metrics/AbcSize, Metrics/MethodLength def metamorph(datum) case datum.class.name when 'Array' data = datum.first if data.is_a?(Array) datum.map { |arr| arr.map { |val| metaform(val) } } elsif data.is_a?(Hash) datum.map { |hsh| hsh.each { |key, val| hash.store(key, metaform(val)) } } else datum.map { |val| metaform(val) } end when 'Hash' datum.each { |key, val| datum.store(key, metaform(val)) } else metaform(datum) end end # rubocop:enable Metrics/AbcSize, Metrics/MethodLength def metatransform(datum) return(nil) if datum.empty? evaluate? ? metamorph(datum) : datum end def milliseconds?(format) format.to_s == 'milliseconds' end def normalize_key(key) key.to_s end def prepend?(order) order.to_s == 'prepend' end def seconds?(format) format.to_s == 'seconds' end def stringify_keys(value) value.map { |key, _| key.to_s } end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
active_orm-4.0.3 | lib/active_orm/redis/base.rb |
active_orm-4.0.2 | lib/active_orm/redis/base.rb |