lite-command 2.1.3 → 3.0.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -1,46 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- module Lite
4
- module Command
5
- module Internals
6
- module Context
7
-
8
- def self.included(base)
9
- base.extend ClassMethods
10
- end
11
-
12
- module ClassMethods
13
-
14
- def attribute(*args, **options)
15
- args.each do |method_name|
16
- attribute = Lite::Command::Attribute.new(method_name, options)
17
- attributes[method_name] = attribute
18
-
19
- define_method(method_name) do
20
- ivar = :"@#{method_name}"
21
- return instance_variable_get(ivar) if instance_variable_defined?(ivar)
22
-
23
- instance_variable_set(ivar, attribute.value)
24
- end
25
- end
26
- end
27
-
28
- def attributes
29
- @attributes ||= {}
30
- end
31
-
32
- end
33
-
34
- private
35
-
36
- def validate_context_attributes
37
- validator = Lite::Command::AttributeValidator.new(self)
38
- return if validator.valid?
39
-
40
- invalid!("Invalid context attributes", validator.errors)
41
- end
42
-
43
- end
44
- end
45
- end
46
- end