class Virtus::Attribute::DefaultValue::FromSymbol

Represents default value evaluated via a symbol

@api private

Public Class Methods

handle?(value) click to toggle source

Return if the class can handle the value

@param [Object] value

@return [Boolean]

@api private

# File lib/virtus/attribute/default_value/from_symbol.rb, line 17
def self.handle?(value)
  value.is_a?(Symbol)
end

Public Instance Methods

call(instance, _) click to toggle source

Evaluates the value via instance#public_send(value)

Symbol value is returned if the instance doesn't respond to value

@return [Object] evaluated value

@api private

# File lib/virtus/attribute/default_value/from_symbol.rb, line 28
def call(instance, _)
  instance.respond_to?(@value, true) ? instance.send(@value) : @value
end