Module: Airtable::ORM::Core

Extended by:
ActiveSupport::Concern
Included in:
Base
Defined in:
lib/airtable/orm/core.rb

Instance Method Summary collapse

Instance Method Details

#==(other) ⇒ Object Also known as: eql?

Instance comparison



9
10
11
12
13
14
# File 'lib/airtable/orm/core.rb', line 9

def ==(other)
  return false unless other.is_a?(self.class)
  return false if new_record? || other.new_record?

  id == other.id
end

#freezeObject

Freeze the record



42
43
44
45
46
# File 'lib/airtable/orm/core.rb', line 42

def freeze
  @id.freeze
  @created_at.freeze
  super
end

#hashObject



18
19
20
# File 'lib/airtable/orm/core.rb', line 18

def hash
  [self.class, id].hash
end

#inspectObject

Inspect method for better debugging



23
24
25
26
27
28
29
30
# File 'lib/airtable/orm/core.rb', line 23

def inspect
  attribute_string = self.class.attribute_types.map do |name, _type|
    value = read_raw_attribute(name.to_sym)
    "#{name}: #{value.inspect}"
  end.join(", ")

  "#<#{self.class.name} id: #{id.inspect}, #{attribute_string}>"
end

#to_hObject

Convert to hash with symbol keys



33
34
35
36
37
38
39
# File 'lib/airtable/orm/core.rb', line 33

def to_h
  {
    id: id,
    created_at: created_at,
    **symbol_attributes
  }
end