Module: CouchbaseOrm::ActiveRecordCompat::ClassMethods

Defined in:
lib/couchbase-orm/base.rb

Instance Method Summary collapse

Instance Method Details

#_reflect_on_association(_attribute) ⇒ Object



77
78
79
# File 'lib/couchbase-orm/base.rb', line 77

def _reflect_on_association(_attribute)
  false
end

#abstract_class?Boolean

Returns:



55
56
57
# File 'lib/couchbase-orm/base.rb', line 55

def abstract_class?
  false
end

#attribute_namesObject



94
95
96
# File 'lib/couchbase-orm/base.rb', line 94

def attribute_names
  attribute_types.keys
end

#attributes_builderObject

:nodoc:



85
86
87
88
89
90
91
# File 'lib/couchbase-orm/base.rb', line 85

def attributes_builder # :nodoc:
  unless defined?(@attributes_builder) && @attributes_builder
    defaults = _default_attributes
    @attributes_builder = ActiveModel::AttributeSet::Builder.new(attribute_types, defaults)
  end
  @attributes_builder
end

#base_class?Boolean

Returns:



46
47
48
# File 'lib/couchbase-orm/base.rb', line 46

def base_class?
  true
end

#column_namesObject

can’t be an alias for now



51
52
53
# File 'lib/couchbase-orm/base.rb', line 51

def column_names
  attribute_names
end

#composite_primary_key?Boolean

ActiveRecord 7.1 compatibility

Returns:



73
74
75
# File 'lib/couchbase-orm/base.rb', line 73

def composite_primary_key?
  false
end

#connected?Boolean

Returns:



59
60
61
# File 'lib/couchbase-orm/base.rb', line 59

def connected?
  true
end

#connectionObject

Stub connection for ActiveRecord::Timestamp compatibility



68
69
70
# File 'lib/couchbase-orm/base.rb', line 68

def connection
  @connection ||= Struct.new(:default_timezone).new(:utc)
end

#generate_alias_attributes(*args) ⇒ Object



103
104
105
106
107
108
109
# File 'lib/couchbase-orm/base.rb', line 103

def generate_alias_attributes(*args)
  # In Rails 7.1+, this method was renamed and signature changed
  # ActiveRecord 7.1 still calls it with no args, so we handle that case
  return if args.empty?

  generate_alias_attribute_methods(*args)
end

#primary_keyObject



42
43
44
# File 'lib/couchbase-orm/base.rb', line 42

def primary_key
  'id'
end

#table_exists?Boolean

Returns:



63
64
65
# File 'lib/couchbase-orm/base.rb', line 63

def table_exists?
  true
end

#type_for_attribute(attribute) ⇒ Object



81
82
83
# File 'lib/couchbase-orm/base.rb', line 81

def type_for_attribute(attribute)
  attribute_types[attribute]
end