Module: Filemaker::Model

Extended by:
ActiveSupport::Concern
Includes:
Components
Defined in:
lib/filemaker/model.rb,
lib/filemaker/model/type.rb,
lib/filemaker/model/field.rb,
lib/filemaker/model/fields.rb,
lib/filemaker/model/batches.rb,
lib/filemaker/model/builder.rb,
lib/filemaker/model/criteria.rb,
lib/filemaker/model/findable.rb,
lib/filemaker/model/optional.rb,
lib/filemaker/model/relations.rb,
lib/filemaker/model/components.rb,
lib/filemaker/model/pagination.rb,
lib/filemaker/model/selectable.rb,
lib/filemaker/model/types/date.rb,
lib/filemaker/model/types/text.rb,
lib/filemaker/model/types/time.rb,
lib/filemaker/model/persistable.rb,
lib/filemaker/model/types/email.rb,
lib/filemaker/model/types/integer.rb,
lib/filemaker/model/relations/proxy.rb,
lib/filemaker/model/types/date_time.rb,
lib/filemaker/model/types/big_decimal.rb,
lib/filemaker/model/relations/has_many.rb,
lib/filemaker/model/relations/belongs_to.rb,
lib/filemaker/model/relations/has_portal.rb

Defined Under Namespace

Modules: Batches, Builder, ClassMethods, Components, Fields, Findable, Optional, Pagination, Persistable, Relations, Selectable, Type, Types Classes: Criteria, Field

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods included from Persistable

#create, #destroy, #reload!, #save, #save!, #update, #update_attributes, #update_attributes!

Methods included from Fields

#apply_defaults, #attribute_names, #attributes, #fm_names

Instance Attribute Details

#mod_idObject (readonly)

Returns the value of attribute mod_id.



8
9
10
# File 'lib/filemaker/model.rb', line 8

def mod_id
  @mod_id
end

#new_recordObject (readonly)

Returns the value of attribute new_record.



8
9
10
# File 'lib/filemaker/model.rb', line 8

def new_record
  @new_record
end

#portalsObject (readonly)

Returns the value of attribute portals.



8
9
10
# File 'lib/filemaker/model.rb', line 8

def portals
  @portals
end

#record_idObject (readonly)

Returns the value of attribute record_id.



8
9
10
# File 'lib/filemaker/model.rb', line 8

def record_id
  @record_id
end

Instance Method Details

#cache_keyObject



42
43
44
45
46
47
# File 'lib/filemaker/model.rb', line 42

def cache_key
  return "#{model_key}/new" if new_record?
  return "#{model_key}/#{id}-#{updated_at.to_datetime.utc.to_s(:number)}" if respond_to?(:updated_at) && send(:updated_at)

  "#{model_key}/#{id}"
end

#create_attributesObject



65
66
67
# File 'lib/filemaker/model.rb', line 65

def create_attributes
  self.class.with_model_fields_for_creation(attributes)
end

#dirty_attributesObject



69
70
71
72
73
74
75
76
77
# File 'lib/filemaker/model.rb', line 69

def dirty_attributes
  dirty = {}
  changed.each do |attr_name|
    dirty[attr_name] = attributes[attr_name]
  end

  # We need to use serialize_for_update instead
  self.class.with_model_fields_for_update(dirty)
end

#fm_attributesObject



61
62
63
# File 'lib/filemaker/model.rb', line 61

def fm_attributes
  self.class.with_model_fields_for_query(attributes)
end

#idObject



49
50
51
# File 'lib/filemaker/model.rb', line 49

def id
  self.class.identity ? identity_id : record_id
end

#identity_idObject



53
54
55
# File 'lib/filemaker/model.rb', line 53

def identity_id
  public_send(identity.name) if identity
end

#initialize(attributes = {}) ⇒ Object



15
16
17
18
19
20
21
22
23
24
# File 'lib/filemaker/model.rb', line 15

def initialize(attributes = {})
  # We did not manage to use `ActiveModel::AttributeAssignment`
  # super

  @new_record = true
  @relations = {}
  apply_defaults
  process_attributes(attributes)
  clear_changes_information
end

#model_keyObject



38
39
40
# File 'lib/filemaker/model.rb', line 38

def model_key
  @model_key ||= self.class.model_name.cache_key
end

#new_record?Boolean

Returns:

  • (Boolean)


26
27
28
# File 'lib/filemaker/model.rb', line 26

def new_record?
  new_record
end

#persisted?Boolean

Returns:

  • (Boolean)


30
31
32
# File 'lib/filemaker/model.rb', line 30

def persisted?
  !new_record?
end

#to_aObject



34
35
36
# File 'lib/filemaker/model.rb', line 34

def to_a
  [self]
end

#to_paramObject



57
58
59
# File 'lib/filemaker/model.rb', line 57

def to_param
  id&.to_s
end