Sha256: efcecee4430d332c673aa4bc4c7f7d04caf29d1b44d492ce2fe6009dbf7608ea
Contents?: true
Size: 1.15 KB
Versions: 2
Compression:
Stored size: 1.15 KB
Contents
# frozen_string_literal: true module ActiveSerialize module ClassMethods def _active_serialize ActiveSerialize.configs[name] ||= { **ActiveSerialize.configs[:default].deep_dup, final: nil, groups: { }, recursive: [ ], map: { }, pluck: [ ] } end def to_ha(*args) all.to_ha(*args) end def active_serialize_rmv *attrs _active_serialize[:rmv].concat attrs.map(&:to_sym) end # to: `recursive` or `pluck` def active_serialize_add *attrs, named: nil, to: nil, group: nil active_serialize_map attrs[0] => named if named return _active_serialize[:groups][group] = attrs.map(&:to_sym) if group _active_serialize[to || :add].concat attrs.map(&:to_sym) end def active_serialize_map **settings _active_serialize[:map].merge! settings end def active_serialize_keys(*groups, rmv: [ ], add: [ ]) _active_serialize[:final] ||= column_names.map(&:to_sym) - _active_serialize[:rmv] + _active_serialize[:add] _active_serialize[:final] - Array(rmv) + Array(add) + _active_serialize[:groups].values_at(*groups).flatten.compact.uniq end end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
active_serialize-2.4.2 | lib/active_serialize/class_methods.rb |
active_serialize-2.4.0 | lib/active_serialize/class_methods.rb |