Sha256: 61521a663eaf87de8a9c7d4ce93198efe5c9c0edac9d517789f913f877a34e3d

Contents?: true

Size: 1.51 KB

Versions: 37

Compression:

Stored size: 1.51 KB

Contents

module Eco
  module API
    module Common
      module Loaders
        class Base
          extend Eco::API::Common::ClassHelpers

          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
            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

          def name
            self.class.name
          end

          private

          def session
            ASSETS.session
          end

          def config
            session.config
          end

          def logger
            session.logger
          end

          def micro
            session.micro
          end

          def abort(msg, raising: true)
            logger.error(msg)
            if raising
              raise msg
            else
              exit(1)
            end
          end
        end
      end
    end
  end
end

Version data entries

37 entries across 37 versions & 1 rubygems

Version Path
eco-helpers-2.4.8 lib/eco/api/common/loaders/base.rb
eco-helpers-2.4.7 lib/eco/api/common/loaders/base.rb
eco-helpers-2.4.6 lib/eco/api/common/loaders/base.rb
eco-helpers-2.4.5 lib/eco/api/common/loaders/base.rb
eco-helpers-2.4.4 lib/eco/api/common/loaders/base.rb
eco-helpers-2.4.3 lib/eco/api/common/loaders/base.rb
eco-helpers-2.4.2 lib/eco/api/common/loaders/base.rb
eco-helpers-2.3.3 lib/eco/api/common/loaders/base.rb
eco-helpers-2.3.2 lib/eco/api/common/loaders/base.rb
eco-helpers-2.2.5 lib/eco/api/common/loaders/base.rb
eco-helpers-2.2.4 lib/eco/api/common/loaders/base.rb
eco-helpers-2.2.3 lib/eco/api/common/loaders/base.rb
eco-helpers-2.2.2 lib/eco/api/common/loaders/base.rb
eco-helpers-2.2.1 lib/eco/api/common/loaders/base.rb
eco-helpers-2.1.12 lib/eco/api/common/loaders/base.rb
eco-helpers-2.1.11 lib/eco/api/common/loaders/base.rb
eco-helpers-2.1.10 lib/eco/api/common/loaders/base.rb
eco-helpers-2.1.9 lib/eco/api/common/loaders/base.rb
eco-helpers-2.1.8 lib/eco/api/common/loaders/base.rb
eco-helpers-2.1.7 lib/eco/api/common/loaders/base.rb