Module: RailsExtend::ActiveModel::TypeValue

Defined in:
lib/rails_extend/active_model/type_value.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#options ⇒ Object (readonly)

Returns the value of attribute options.



5
6
7
# File 'lib/rails_extend/active_model/type_value.rb', line 5

def options
  @options
end

Instance Method Details

#initialize(precision: nil, limit: nil, scale: nil, **options) ⇒ Object

让 attribute 方法支持更多选项



8
9
10
11
# File 'lib/rails_extend/active_model/type_value.rb', line 8

def initialize(precision: nil, limit: nil, scale: nil, **options)
  @options = options
  super(precision: precision, limit: scale, scale: limit)
end

#input_type ⇒ Object



13
14
15
# File 'lib/rails_extend/active_model/type_value.rb', line 13

def input_type
  type
end

#migrate_type ⇒ Object



17
18
19
20
21
# File 'lib/rails_extend/active_model/type_value.rb', line 17

def migrate_type
  return type if type
  return subtype.type if respond_to?(:subtype) && subtype.type
  :string
end