Sha256: b311a0619cbb3087550d99c22325372e007a201a12c0ae502956d22acbe0dfa2
Contents?: true
Size: 967 Bytes
Versions: 3
Compression:
Stored size: 967 Bytes
Contents
module Tdc module ExtendedAttributes class DefaultInterpreter < Tdc::ExtendedAttributes::InterpreterBase def interpret(instance_definition) extended_attribute_definitions = keep_extended_attributes(instance_definition) extended_attribute_definitions.each do |k, v| # Remove the original extended attribute. instance_definition.delete(k) # Add a standard attribute. instance_definition[convert_to_standard_attribute(k)] = extended_attribute_context.instance_eval(v) end end concerning :HookMethods do def convert_to_standard_attribute(k) # rubocop:disable Naming/MethodParameterName k.delete_suffix("x") end def extended_attribute_context Time.zone end def keep_extended_attributes(instance_definition) instance_definition.select { |k, _v| /_(at|date|on)x$/ =~ k } end end end end end
Version data entries
3 entries across 3 versions & 1 rubygems
Version | Path |
---|---|
tdc-0.4.0 | lib/tdc/extended_attributes/default_interpreter.rb |
tdc-0.3.9 | lib/tdc/extended_attributes/default_interpreter.rb |
tdc-0.3.8 | lib/tdc/extended_attributes/default_interpreter.rb |