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-1.3.2 lib/acfs/resource/loadable.rb
acfs-1.3.1 lib/acfs/resource/loadable.rb
acfs-1.3.0 lib/acfs/resource/loadable.rb
acfs-1.2.1 lib/acfs/resource/loadable.rb
acfs-0.50.0 lib/acfs/resource/loadable.rb
acfs-1.2.0 lib/acfs/resource/loadable.rb
acfs-0.49.1 lib/acfs/resource/loadable.rb
acfs-1.1.1 lib/acfs/resource/loadable.rb
acfs-0.49.0 lib/acfs/resource/loadable.rb
acfs-1.1.0 lib/acfs/resource/loadable.rb
acfs-0.48.2 lib/acfs/resource/loadable.rb
acfs-1.0.1 lib/acfs/resource/loadable.rb
acfs-0.48.1 lib/acfs/resource/loadable.rb
acfs-1.0.0 lib/acfs/resource/loadable.rb
acfs-0.48.0 lib/acfs/resource/loadable.rb
acfs-0.47.0 lib/acfs/resource/loadable.rb
acfs-0.46.0 lib/acfs/resource/loadable.rb
acfs-0.45.0 lib/acfs/resource/loadable.rb
acfs-0.44.0 lib/acfs/resource/loadable.rb
acfs-0.43.2 lib/acfs/resource/loadable.rb