Class: ViewModel::Metadata

Inherits:
Struct
  • Object
show all
Defined in:
lib/view_model.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#idObject

Returns the value of attribute id



41
42
43
# File 'lib/view_model.rb', line 41

def id
  @id
end

#migratedObject

Returns the value of attribute migrated



41
42
43
# File 'lib/view_model.rb', line 41

def migrated
  @migrated
end

#newObject

Returns the value of attribute new



41
42
43
# File 'lib/view_model.rb', line 41

def new
  @new
end

#schema_versionObject

Returns the value of attribute schema_version



41
42
43
# File 'lib/view_model.rb', line 41

def schema_version
  @schema_version
end

#view_nameObject

Returns the value of attribute view_name



41
42
43
# File 'lib/view_model.rb', line 41

def view_name
  @view_name
end

Instance Method Details

#auto_child_update?Boolean

Does this child metadata describe an create-or-update to the anonymous child of a singular association



66
67
68
# File 'lib/view_model.rb', line 66

def auto_child_update?
  new == 'auto'
end

#child_update?Boolean

Does this metadata describe an change to the anonymous child of a singular association



54
55
56
# File 'lib/view_model.rb', line 54

def child_update?
  explicit_child_update? || auto_child_update?
end

#explicit_child_update?Boolean

Does this metadata describe an update to the already-existing anonymous child of a singular association



60
61
62
# File 'lib/view_model.rb', line 60

def explicit_child_update?
  new == false && id.nil?
end

#new?Boolean

Does this metadata describe deserialization to a new model, either by true or nil, id: nil



44
45
46
47
48
49
50
# File 'lib/view_model.rb', line 44

def new?
  if new.nil?
    id.nil?
  else
    new == true
  end
end