Sha256: 11626051724dafb9f76576a4f13aeb39521ed218df8476db965ee490d95f2c11

Contents?: true

Size: 711 Bytes

Versions: 22

Compression:

Stored size: 711 Bytes

Contents

class Acfs::Resource
  # Provides method to check for loading state of resources.
  # A resource that is created but not yet fetched will be loaded
  # after running {Acfs::Global#run Acfs.run}.
  #
  # @example
  #   user = User.find 5
  #   user.loaded? # => false
  #   Acfs.run
  #   user.loaded? # => true
  #
  module Loadable
    extend ActiveSupport::Concern

    # @api public
    #
    # Check if model is loaded or if request is still queued.
    #
    # @return [Boolean] True if resource is loaded, false otherwise.
    #
    def loaded?
      @loaded.nil? ? false : @loaded
    end

    # @api private
    #
    # Mark model as loaded.
    #
    def loaded!
      @loaded = true
    end
  end
end

Version data entries

22 entries across 22 versions & 1 rubygems

Version Path
acfs-0.43.1 lib/acfs/resource/loadable.rb
acfs-0.43.0 lib/acfs/resource/loadable.rb