Class: Eco::CliDefault::People
Constant Summary
collapse
- MAX_GET_PARTIAL =
12_000
Class Attribute Summary collapse
Class Method Summary
collapse
config
active_enviro, cli, config, config_block
#class_resolver, #descendants, #descendants?, #inheritable_attrs, #inheritable_class_vars, #inherited, #instance_variable_name, #new_class, #resolve_class, #to_constant
#delegate_missing_to, #method_missing, #respond_to_missing?
Class Attribute Details
.get_full=(value) ⇒ Object
Sets the attribute get_full
6
7
8
|
# File 'lib/eco/cli_default/people.rb', line 6
def get_full=(value)
@get_full = value
end
|
.get_partial=(value) ⇒ Object
Sets the attribute get_partial
6
7
8
|
# File 'lib/eco/cli_default/people.rb', line 6
def get_partial=(value)
@get_partial = value
end
|
Returns the value of attribute options.
5
6
7
|
# File 'lib/eco/cli_default/people.rb', line 5
def options
@options
end
|
Returns the value of attribute session.
5
6
7
|
# File 'lib/eco/cli_default/people.rb', line 5
def session
@session
end
|
Class Method Details
.from_local? ⇒ Boolean
24
25
26
27
28
|
# File 'lib/eco/cli_default/people.rb', line 24
def from_local?
return false unless get_options
get_options[:from] == :local
end
|
.from_remote? ⇒ Boolean
18
19
20
21
22
|
# File 'lib/eco/cli_default/people.rb', line 18
def from_remote?
return false unless get_options
get_options[:from] == :remote
end
|
.get_by_file? ⇒ Boolean
44
45
46
47
48
|
# File 'lib/eco/cli_default/people.rb', line 44
def get_by_file?
return false unless from_local?
get_options[:type] == :file
end
|
.get_full? ⇒ Boolean
30
31
32
33
34
35
|
# File 'lib/eco/cli_default/people.rb', line 30
def get_full?
return @get_full if instance_variable_defined?(:@get_full)
return false unless from_remote?
get_options[:type] == :full
end
|
.get_options ⇒ Object
rubocop:disable Naming/AccessorMethodName
8
9
10
11
12
|
# File 'lib/eco/cli_default/people.rb', line 8
def get_options get = options.dig(:people, :get)
get = {} if get.nil?
get
end
|
.get_partial? ⇒ Boolean
37
38
39
40
41
42
|
# File 'lib/eco/cli_default/people.rb', line 37
def get_partial?
return @get_partial if instance_variable_defined?(:@get_partial)
return false unless from_remote?
@get_partial = (get_options[:type] == :partial)
end
|
.no_get? ⇒ Boolean
14
15
16
|
# File 'lib/eco/cli_default/people.rb', line 14
def no_get?
get_options == false
end
|
.optimize_get_partial!(input) ⇒ Object
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
|
# File 'lib/eco/cli_default/people.rb', line 80
def optimize_get_partial!(input)
return unless get_partial?
msg = "To use -get-partial (partial updates), you need to use -entries-from"
raise msg unless input.is_a?(Enumerable)
return unless input.count > MAX_GET_PARTIAL
msg = "(Optimization) "
msg << "Switching from partial to full people download. "
msg << "Input (#{input.count}) surpases MAX_GET_PARTIAL "
msg << "(#{MAX_GET_PARTIAL}) entries."
session.log(:info) { msg }
switch_to_full_remote!
end
|
.source_file ⇒ Object
50
51
52
53
54
|
# File 'lib/eco/cli_default/people.rb', line 50
def source_file
return unless get_by_file?
get_options[:file]
end
|
.switch_to_full_local! ⇒ Object
68
69
70
71
72
73
74
75
76
77
78
|
# File 'lib/eco/cli_default/people.rb', line 68
def switch_to_full_local!
self.get_full = true
self.get_partial = false
options.deep_merge!(people: {
get: {
from: :local,
type: :full
}
})
end
|
.switch_to_full_remote! ⇒ Object
56
57
58
59
60
61
62
63
64
65
66
|
# File 'lib/eco/cli_default/people.rb', line 56
def switch_to_full_remote!
self.get_full = true
self.get_partial = false
options.deep_merge!(people: {
get: {
from: :remote,
type: :full
}
})
end
|