Sha256: ed04384e805b913024cd736884a4eed539a60e748bd9f8d3ad1f94613a5de7e1

Contents?: true

Size: 1.33 KB

Versions: 4

Compression:

Stored size: 1.33 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

        end
      end
    end
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
eco-helpers-2.0.29 lib/eco/api/common/loaders/base.rb
eco-helpers-2.0.28 lib/eco/api/common/loaders/base.rb
eco-helpers-2.0.27 lib/eco/api/common/loaders/base.rb
eco-helpers-2.0.26 lib/eco/api/common/loaders/base.rb