Sha256: 86d1b2a44433aae8ffaf94605e9866eeab1780afa2d0430ea7004f5c6b43f651

Contents?: true

Size: 772 Bytes

Versions: 9

Compression:

Stored size: 772 Bytes

Contents

module Virtus
  class Attribute
    class DefaultValue

      # Represents default value evaluated via a callable object
      #
      # @api private
      class FromCallable < DefaultValue

        # Return if the class can handle the value
        #
        # @param [Object] value
        #
        # @return [Boolean]
        #
        # @api private
        def self.handle?(value)
          value.respond_to?(:call)
        end

        # Evaluates the value via value#call
        #
        # @param [Object]
        #
        # @return [Object] evaluated value
        #
        # @api private
        def call(*args)
          @value.call(*args)
        end

      end # class FromCallable
    end # class DefaultValue
  end # class Attribute
end # module Virtus

Version data entries

9 entries across 9 versions & 2 rubygems

Version Path
virtus-0.5.5 lib/virtus/attribute/default_value/from_callable.rb
virtus-0.5.4 lib/virtus/attribute/default_value/from_callable.rb
virtus-0.5.3 lib/virtus/attribute/default_value/from_callable.rb
fragrant-0.0.5 vendor/bundle/ruby/1.9.1/gems/virtus-0.5.2/lib/virtus/attribute/default_value/from_callable.rb
virtus-0.5.2 lib/virtus/attribute/default_value/from_callable.rb
virtus-0.5.1 lib/virtus/attribute/default_value/from_callable.rb
virtus-0.5.0 lib/virtus/attribute/default_value/from_callable.rb
virtus-0.4.2 lib/virtus/attribute/default_value/from_callable.rb
virtus-0.4.1 lib/virtus/attribute/default_value/from_callable.rb