Sha256: 8d8c23a198a55ea4a01469626d0716bb311fbac4a0ced3a73f6e683522b0b12b

Contents?: true

Size: 1.66 KB

Versions: 37

Compression:

Stored size: 1.66 KB

Contents

module Eco
  module API
    module Common
      module Loaders
        class Base
          extend Eco::API::Common::ClassHelpers
          include Eco::Language::AuxiliarLogger

          class << self
            # Sort order
            def <=>(other)
              created_at <=> other.created_at
            end

            # If still not set, it sets the `created_at` class timestamp.
            def set_created_at!
              @created_at ||= Time.now unless @created_at # rubocop:disable Naming/MemoizedInstanceVariableName
            end

            # Class creation timestamp, to be able to load them in the order they were declared.
            def created_at
              @created_at ||= Time.now
            end
          end

          # This method will be called when the BaseLoader is created
          # @note
          #   - this method should implement the loading logics for the given `Children` class.
          def initialize
            raise "You should implement this method"
          end

          private

          def simulate?
            options[:simulate] || options[:dry_run]
          end
          alias_method :dry_run?, :simulate?

          def session
            @session ||= ASSETS.session
          end

          def options
            @options ||= {}
          end

          def config
            session.config
          end

          def micro
            session.micro
          end

          def abort(msg, raising: true)
            log(:error) { msg }
            exit(1) unless raising

            raise msg
          end
        end
      end
    end
  end
end

Version data entries

37 entries across 37 versions & 1 rubygems

Version Path
eco-helpers-3.0.1 lib/eco/api/common/loaders/base.rb
eco-helpers-3.0.0 lib/eco/api/common/loaders/base.rb
eco-helpers-2.7.25 lib/eco/api/common/loaders/base.rb
eco-helpers-2.7.24 lib/eco/api/common/loaders/base.rb
eco-helpers-2.7.23 lib/eco/api/common/loaders/base.rb
eco-helpers-2.7.22 lib/eco/api/common/loaders/base.rb
eco-helpers-2.7.21 lib/eco/api/common/loaders/base.rb
eco-helpers-2.7.20 lib/eco/api/common/loaders/base.rb
eco-helpers-2.7.19 lib/eco/api/common/loaders/base.rb
eco-helpers-2.7.18 lib/eco/api/common/loaders/base.rb
eco-helpers-2.7.17 lib/eco/api/common/loaders/base.rb
eco-helpers-2.7.16 lib/eco/api/common/loaders/base.rb
eco-helpers-2.7.15 lib/eco/api/common/loaders/base.rb
eco-helpers-2.7.14 lib/eco/api/common/loaders/base.rb
eco-helpers-2.7.13 lib/eco/api/common/loaders/base.rb
eco-helpers-2.7.12 lib/eco/api/common/loaders/base.rb
eco-helpers-2.7.4 lib/eco/api/common/loaders/base.rb