Class: DbSchema::Definitions::Field::Custom

Inherits:
Base
  • Object
show all
Defined in:
lib/db_schema/definitions/field/custom.rb

Instance Attribute Summary

Attributes inherited from Base

#default, #name

Class Method Summary collapse

Methods inherited from Base

#array?, attributes, #attributes, #custom?, default_attribute_values, #default_is_expression?, #initialize, #null?, #options, #primary_key?, register, #type, type, valid_attributes, #with_attribute, #with_type

Constructor Details

This class inherits a constructor from DbSchema::Definitions::Field::Base

Class Method Details

.class_for(type_name) ⇒ Object

Raises:

  • (ArgumentError)


6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
# File 'lib/db_schema/definitions/field/custom.rb', line 6

def class_for(type_name)
  raise ArgumentError if type_name.nil?

  custom_types[type_name] ||= Class.new(self) do
    define_method :type do
      type_name
    end

    define_singleton_method :type do
      type_name
    end

    define_method :custom? do
      true
    end
  end
end