Class: TableSync::ORMAdapter::ActiveRecord

Inherits:
Base
  • Object
show all
Defined in:
lib/table_sync/orm_adapter/active_record.rb

Instance Attribute Summary

Attributes inherited from Base

#object, #object_class, #object_data

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from Base

#attributes_for_destroy, #attributes_for_headers, #attributes_for_routing_key, #attributes_for_update, #empty?, #initialize, #needle, #primary_key_columns, #validate!

Constructor Details

This class inherits a constructor from TableSync::ORMAdapter::Base

Class Method Details

.model_naming(object_class) ⇒ Object



5
6
7
# File 'lib/table_sync/orm_adapter/active_record.rb', line 5

def self.model_naming(object_class)
  TableSync::NamingResolver::ActiveRecord.new(table_name: object_class.table_name)
end

Instance Method Details

#attributesObject



21
22
23
# File 'lib/table_sync/orm_adapter/active_record.rb', line 21

def attributes
  object.attributes.symbolize_keys
end

#findObject



9
10
11
12
13
# File 'lib/table_sync/orm_adapter/active_record.rb', line 9

def find
  @object = object_class.find_by(needle)

  super
end

#initObject



15
16
17
18
19
# File 'lib/table_sync/orm_adapter/active_record.rb', line 15

def init
  @object = object_class.new(object_data)

  super
end