Sha256: a3f30e80f5683abf5ea21caeb06cda478b88612df22a3963118d45c21535f1fe

Contents?: true

Size: 823 Bytes

Versions: 15

Compression:

Stored size: 823 Bytes

Contents

module Ardm
  module Subject
    # Returns a default value of the subject for given resource
    #
    # When default value is a callable object, it is called with resource
    # and subject passed as arguments.
    #
    # @param [Resource] resource
    #   the model instance for which the default is to be set
    #
    # @return [Object]
    #   the default value of this subject for +resource+
    #
    # @api semipublic
    def default_for(resource)
      if @default.respond_to?(:call)
        @default.call(resource, self)
      else
        Ardm::Ext.try_dup(@default)
      end
    end

    # Returns true if the subject has a default value
    #
    # @return [Boolean]
    #   true if the subject has a default value
    #
    # @api semipublic
    def default?
      @options.key?(:default)
    end
  end
end

Version data entries

15 entries across 15 versions & 1 rubygems

Version Path
ardm-0.4.0.ar427 lib/ardm/support/subject.rb
ardm-0.4.0 lib/ardm/support/subject.rb
ardm-0.3.2 lib/ardm/support/subject.rb
ardm-0.3.1 lib/ardm/support/subject.rb
ardm-0.3.0 lib/ardm/support/subject.rb
ardm-0.2.7 lib/ardm/support/subject.rb
ardm-0.2.6 lib/ardm/support/subject.rb
ardm-0.2.5 lib/ardm/support/subject.rb
ardm-0.2.4 lib/ardm/support/subject.rb
ardm-0.2.3 lib/ardm/support/subject.rb
ardm-0.2.2 lib/ardm/support/subject.rb
ardm-0.2.1 lib/ardm/support/subject.rb
ardm-0.2.0 lib/ardm/support/subject.rb
ardm-0.1.0 lib/ardm/support/subject.rb
ardm-0.0.1 lib/ardm/support/subject.rb