Sha256: 7303fafedf385e568e310d6bafeaba97c03c1777d6cc76a81460771a743dd867

Contents?: true

Size: 712 Bytes

Versions: 3

Compression:

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

3 entries across 3 versions & 1 rubygems

Version Path
acfs-1.0.0.dev.1.b305 lib/acfs/resource/loadable.rb
acfs-1.0.0.dev.1.b298 lib/acfs/resource/loadable.rb
acfs-1.0.0.dev.1.b297 lib/acfs/resource/loadable.rb