Sha256: 6616afc64aa3c560dcd49c7626d640d8e72b9889062e2fda3474aa3155c14024
Contents?: true
Size: 954 Bytes
Versions: 2
Compression:
Stored size: 954 Bytes
Contents
# frozen_string_literal: true require "ostruct" unless defined?(OpenStruct) module Lite module Command class Context < OpenStruct def self.init(attributes = {}) # To save memory and speed up the access to an attribute, the accessor methods # of an attribute are lazy loaded at certain points. This means that the methods # are defined only when a set of defined actions are triggered. This allows context # to only define the minimum amount of required methods to make your data structure work os = new(attributes) os.methods(false) os end def self.build(attributes = {}) return attributes if attributes.is_a?(self) && !attributes.frozen? init(attributes.to_h) end def merge!(attributes = {}) attrs = attributes.is_a?(self.class) ? attributes.to_h : attributes attrs.each { |k, v| self[k] = v } end end end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
lite-command-2.0.1 | lib/lite/command/context.rb |
lite-command-2.0.0 | lib/lite/command/context.rb |