class AMA::Entity::Mapper::Context
Base class for various contexts, created to define common ground for any traversal operations
Attributes
include_sensitive_attributes[R]
@!attribute [r] include_sensitive_attributes
@return [FalseClass, TrueClass]
logger[R]
@!attribute [r] logger
@return [Logger]
path[R]
@!attribute [r] path
@return [AMA::Entity::Mapper::Path]
strict[R]
@!attribute [r] strict
@return [FalseClass, TrueClass]
Public Class Methods
new(**options)
click to toggle source
# File lib/ama-entity-mapper/context.rb, line 30 def initialize(**options) defaults = respond_to?(:defaults) ? self.defaults : {} options = defaults.merge(options) defaults.keys.each do |key| instance_variable_set("@#{key}", options[key]) end @logger = @logger.clone @logger.progname = "#{Mapper} #{path}" end
Public Instance Methods
advance(segment)
click to toggle source
Creates new context, resembling traversal to specified segment
@param [AMA::Entity::Mapper::Path::Segment, String, Symbol] segment @return [AMA::Entity::Mapper::Context]
# File lib/ama-entity-mapper/context.rb, line 54 def advance(segment) return self if segment.nil? data = to_h.merge(path: path.push(segment)) self.class.new(**data) end
defaults()
click to toggle source
# File lib/ama-entity-mapper/context.rb, line 40 def defaults { path: Path.new, logger: Logger.new(Aux::NullStream::INSTANCE), strict: true, # Unstable feature, most likely it's name will change include_sensitive_attributes: false } end
to_h()
click to toggle source
# File lib/ama-entity-mapper/context.rb, line 60 def to_h object_variables(self) end