Module: Filemaker::Model

Extended by:
ActiveSupport::Concern
Includes:
Components
Defined in:
lib/filemaker/model.rb,
lib/filemaker/model/field.rb,
lib/filemaker/model/fields.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/persistable.rb,
lib/filemaker/model/relations/proxy.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: Builder, ClassMethods, Components, Fields, Findable, Optional, Pagination, Persistable, Relations, Selectable Classes: Criteria, Field

Constant Summary

Constants included from Fields

Fields::TYPE_MAPPINGS

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods included from Persistable

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

Methods included from Fields

#apply_defaults, #attribute_names, #fm_names

Instance Attribute Details

#attributesBoolean (readonly)

Returns indicates if this is a new fresh record.

Returns:

  • (Boolean)

    indicates if this is a new fresh record



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

def attributes
  @attributes
end

#mod_idBoolean (readonly)

Returns indicates if this is a new fresh record.

Returns:

  • (Boolean)

    indicates if this is a new fresh record



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

def mod_id
  @mod_id
end

#new_recordBoolean (readonly)

Returns indicates if this is a new fresh record.

Returns:

  • (Boolean)

    indicates if this is a new fresh record



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

def new_record
  @new_record
end

#portalsBoolean (readonly)

Returns indicates if this is a new fresh record.

Returns:

  • (Boolean)

    indicates if this is a new fresh record



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

def portals
  @portals
end

#record_idBoolean (readonly)

Returns indicates if this is a new fresh record.

Returns:

  • (Boolean)

    indicates if this is a new fresh record



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

def record_id
  @record_id
end

Instance Method Details

#cache_keyObject



40
41
42
43
44
45
# File 'lib/filemaker/model.rb', line 40

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

#dirty_attributesObject



63
64
65
66
67
68
69
# File 'lib/filemaker/model.rb', line 63

def dirty_attributes
  dirty = {}
  changed.each do |attr_name|
    dirty[attr_name] = attributes[attr_name]
  end
  self.class.with_model_fields(dirty)
end

#fm_attributesObject



59
60
61
# File 'lib/filemaker/model.rb', line 59

def fm_attributes
  self.class.with_model_fields(attributes)
end

#idObject



47
48
49
# File 'lib/filemaker/model.rb', line 47

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

#identity_idObject



51
52
53
# File 'lib/filemaker/model.rb', line 51

def identity_id
  public_send(identity.name) if identity
end

#initialize(attrs = nil) ⇒ Object



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

def initialize(attrs = nil)
  @new_record = true
  @attributes = {}
  @relations = {}
  apply_defaults
  process_attributes(attrs)
end

#model_keyObject



36
37
38
# File 'lib/filemaker/model.rb', line 36

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

#new_record?Boolean

Returns:

  • (Boolean)


24
25
26
# File 'lib/filemaker/model.rb', line 24

def new_record?
  new_record
end

#persisted?Boolean

Returns:

  • (Boolean)


28
29
30
# File 'lib/filemaker/model.rb', line 28

def persisted?
  !new_record?
end

#to_aObject



32
33
34
# File 'lib/filemaker/model.rb', line 32

def to_a
  [self]
end

#to_paramObject



55
56
57
# File 'lib/filemaker/model.rb', line 55

def to_param
  id.to_s if id
end