Class: Lite::Command::Context
- Inherits:
-
OpenStruct
- Object
- OpenStruct
- Lite::Command::Context
- Defined in:
- lib/lite/command/context.rb
Class Method Summary collapse
Instance Method Summary collapse
Class Method Details
.build(attributes = {}) ⇒ Object
19 20 21 22 23 |
# File 'lib/lite/command/context.rb', line 19 def self.build(attributes = {}) return attributes if attributes.is_a?(self) && !attributes.frozen? init(attributes.to_h) end |
.init(attributes = {}) ⇒ Object
9 10 11 12 13 14 15 16 17 |
# File 'lib/lite/command/context.rb', line 9 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 |
Instance Method Details
#merge!(attributes = {}) ⇒ Object
25 26 27 28 |
# File 'lib/lite/command/context.rb', line 25 def merge!(attributes = {}) attrs = attributes.is_a?(self.class) ? attributes.to_h : attributes attrs.each { |k, v| self[k] = v } end |