Class: Eco::API::UseCases::OozeSamples::RegisterExportCase

Inherits:
Common::Loaders::UseCase show all
Includes:
Helpers
Defined in:
lib/eco/api/usecases/ooze_samples/register_export_case.rb

Overview

Note:
  • You can define methods filters and search to change the target entries of the register
  • You need to define the process_ooze method

Use case to offer the basics to export a register This case expects options[:source][:register_id]

Constant Summary

Constants included from Helpers::Filters

Helpers::Filters::FILTER_TIME_FORMAT

Instance Attribute Summary collapse

Attributes included from Language::AuxiliarLogger

#logger

Class Method Summary collapse

Instance Method Summary collapse

Methods included from Helpers::Filters

#date_range_filter, #days, #daystart, #field_key_name, #midnight, #previous_sunday, #set_time, #sunday, #tags_filter, #this_monday, #to_date_filter, #today, #weeks

Methods included from Helpers::Shortcuts

#bracked_regex, #clean_question, #is_number?, #non_letters_regex, #normalize_string, #object_reference, #same_string?, #simplify_string, #titleize, #to_i

Methods inherited from Common::Loaders::UseCase

cli, cli!, #cli_apply!, #initialize, type, #type

Methods inherited from Common::Loaders::CaseBase

#name, name_only_once!

Methods inherited from Common::Loaders::Base

<=>, created_at, #initialize, set_created_at!

Methods included from Common::ClassHelpers

#class_resolver, #descendants, #descendants?, #inheritable_attrs, #inheritable_class_vars, #inherited, #instance_variable_name, #new_class, #resolve_class, #to_constant

Methods included from Language::AuxiliarLogger

#log

Constructor Details

This class inherits a constructor from Eco::API::Common::Loaders::UseCase

Instance Attribute Details

#optionsObject (readonly)

Returns the value of attribute options.



21
22
23
# File 'lib/eco/api/usecases/ooze_samples/register_export_case.rb', line 21

def options
  @options
end

#sessionObject (readonly)

Returns the value of attribute session.



21
22
23
# File 'lib/eco/api/usecases/ooze_samples/register_export_case.rb', line 21

def session
  @session
end

#targetObject (readonly)

Returns the value of attribute target.



22
23
24
# File 'lib/eco/api/usecases/ooze_samples/register_export_case.rb', line 22

def target
  @target
end

#usecaseObject (readonly)

Returns the value of attribute usecase.



21
22
23
# File 'lib/eco/api/usecases/ooze_samples/register_export_case.rb', line 21

def usecase
  @usecase
end

Class Method Details

.batch_size(size = nil) ⇒ Integer

Returns the number of pages to be processed in each batch.

Returns:

  • (Integer)

    the number of pages to be processed in each batch



9
10
11
12
13
# File 'lib/eco/api/usecases/ooze_samples/register_export_case.rb', line 9

def batch_size(size = nil)
  @batch_size ||= 25
  return @batch_size unless size
  @batch_size = size
end

Instance Method Details

#main(_session, options, _usecase) ⇒ Object



24
25
26
27
28
29
30
31
32
33
# File 'lib/eco/api/usecases/ooze_samples/register_export_case.rb', line 24

def main(_session, options, _usecase)
  options[:end_get] = false
  @target = nil
  raise "You need to inherit from this class ('#{self.class}') and call super with a block" unless block_given?

  with_each_entry do |ooze|
    process_ooze(ooze)
  end
  yield
end

#process_ooze(ooze = target) {|ooze| ... } ⇒ Object

Write here your script

Yields:

  • (ooze)


36
37
38
39
# File 'lib/eco/api/usecases/ooze_samples/register_export_case.rb', line 36

def process_ooze(ooze = target)
  raise "You need to inherit from this class ('#{self.class}') and call super with a block" unless block_given?
  yield(ooze)
end