Parent

Files

Virtus::Attribute::Builder

Builder is used to set up an attribute instance based on input type and options

@private

Attributes

attribute[R]
klass[R]
options[R]
type[R]
type_definition[R]

Public Class Methods

call(type, options = {}) click to toggle source

@api private

# File lib/virtus/attribute/builder.rb, line 90
def self.call(type, options = {})
  type_definition = TypeDefinition.new(type)

  if type_definition.pending?
    PendingAttribute.new(type, options)
  else
    new(type_definition, options).attribute
  end
end
determine_type(klass, default = nil) click to toggle source

@api private

# File lib/virtus/attribute/builder.rb, line 101
def self.determine_type(klass, default = nil)
  type = Attribute.determine_type(klass)

  if klass.is_a?(Class)
    type ||=
      if klass < Axiom::Types::Type
        determine_type(klass.primitive)
      elsif EmbeddedValue.handles?(klass)
        EmbeddedValue
      elsif klass < Enumerable && !(klass <= Range)
        Collection
      end
  end

  type || default
end
new(type_definition, options) click to toggle source

@api private

# File lib/virtus/attribute/builder.rb, line 119
def initialize(type_definition, options)
  @type_definition = type_definition

  initialize_class
  initialize_type
  initialize_options(options)
  initialize_default_value
  initialize_coercer
  initialize_attribute
end

[Validate]

Generated with the Darkfish Rdoc Generator 2.