Module: Orthoses::ActiveRecord

Defined in:
lib/orthoses/active_record.rb,
lib/orthoses/active_record/enum.rb,
lib/orthoses/active_record/scope.rb,
lib/orthoses/active_record/has_one.rb,
lib/orthoses/active_record/has_many.rb,
lib/orthoses/active_record/relation.rb,
lib/orthoses/active_record/belongs_to.rb,
lib/orthoses/active_record/persistence.rb,
lib/orthoses/active_record/secure_token.rb,
lib/orthoses/active_record/query_methods.rb,
lib/orthoses/active_record/delegated_type.rb,
lib/orthoses/active_record/generated_attribute_methods.rb

Defined Under Namespace

Classes: BelongsTo, DelegatedType, Enum, GeneratedAttributeMethods, HasMany, HasOne, Persistence, QueryMethods, Relation, Scope, SecureToken

Class Method Summary collapse

Class Method Details

.reflection_klass_name(ref) ⇒ Object



48
49
50
51
52
53
54
55
56
57
# File 'lib/orthoses/active_record.rb', line 48

def self.reflection_klass_name(ref)
  Utils.module_name(ref.klass)
rescue NameError, ArgumentError => e
  while e
    Orthoses.logger.warn(e.message)
    e = e.cause
  end

  nil
end

.sql_type_to_rbs(t) ⇒ Object



18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
# File 'lib/orthoses/active_record.rb', line 18

def self.sql_type_to_rbs(t)
  case t
  when :integer, :big_integer
    '::Integer'
  when :float
    '::Float'
  when :decimal
    '::BigDecimal'
  when :string, :text, :citext, :uuid, :binary, :immutable_string
    '::String'
  when :datetime
    '::ActiveSupport::TimeWithZone'
  when :boolean
    "bool"
  when :date
    '::Date'
  when :time
    '::Time'
  when :cidr, :inet
    "::IPAddr"
  when :bit, :bit_varying, :enum, :hstore,
       :interval, :jsonb, :json, :legacy_point, :money, :point, :vector, :xml
    # FIXME
    'untyped'
  else
    # Unknown column type, give up
    'untyped'
  end
end