Class: Eco::CliDefault::People
- Inherits:
-
API::Common::Loaders::CliConfig
- Object
- API::Common::Loaders::Config
- API::Common::Loaders::CliConfig
- Eco::CliDefault::People
- Defined in:
- lib/eco/cli_default/people.rb
Constant Summary collapse
- MAX_GET_PARTIAL =
12_000
Class Attribute Summary collapse
-
.get_full ⇒ Object
writeonly
Sets the attribute get_full.
-
.get_partial ⇒ Object
writeonly
Sets the attribute get_partial.
-
.options ⇒ Object
readonly
Returns the value of attribute options.
-
.session ⇒ Object
readonly
Returns the value of attribute session.
Class Method Summary collapse
- .from_local? ⇒ Boolean
- .from_remote? ⇒ Boolean
- .get_by_file? ⇒ Boolean
- .get_full? ⇒ Boolean
-
.get_options ⇒ Object
rubocop:disable Naming/AccessorMethodName.
- .get_partial? ⇒ Boolean
- .no_get? ⇒ Boolean
- .optimize_get_partial!(input) ⇒ Object
- .source_file ⇒ Object
- .switch_to_full_local! ⇒ Object
- .switch_to_full_remote! ⇒ Object
Methods inherited from API::Common::Loaders::CliConfig
Class Attribute Details
.get_full=(value) ⇒ Object (writeonly)
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 (writeonly)
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 |
.options ⇒ Object (readonly)
Returns the value of attribute options.
5 6 7 |
# File 'lib/eco/cli_default/people.rb', line 5 def end |
.session ⇒ Object (readonly)
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 [: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 [: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? [: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? [: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 # rubocop:disable Naming/AccessorMethodName get = .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 = ([:type] == :partial) end |
.no_get? ⇒ Boolean
14 15 16 |
# File 'lib/eco/cli_default/people.rb', line 14 def no_get? == 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? [: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 .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 .deep_merge!(people: { get: { from: :remote, type: :full } }) end |