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

Returns:

  • (Object)

    the current value of id



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

def id
  @id
end

#migratedObject

Returns the value of attribute migrated

Returns:

  • (Object)

    the current value of migrated



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

def migrated
  @migrated
end

#newObject

Returns the value of attribute new

Returns:

  • (Object)

    the current value of new



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

def new
  @new
end

#schema_versionObject

Returns the value of attribute schema_version

Returns:

  • (Object)

    the current value of 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

Returns:

  • (Object)

    the current value of 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

Returns:

  • (Boolean)


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

Returns:

  • (Boolean)


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

Returns:

  • (Boolean)


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

Returns:

  • (Boolean)


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