Class: Lutaml::Qea::Models::EaAttribute

Inherits:
BaseModel
  • Object
show all
Defined in:
lib/lutaml/qea/models/ea_attribute.rb

Overview

Represents an attribute from the t_attribute table in EA database This represents class attributes/properties

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from BaseModel

#primary_key

Class Method Details

.from_db_row(row) ⇒ EaAttribute?

Create from database row

Parameters:

  • row (Hash)

    Database row with string keys

Returns:

  • (EaAttribute, nil)

    New instance or nil if row is nil



49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
# File 'lib/lutaml/qea/models/ea_attribute.rb', line 49

def self.from_db_row(row) # rubocop:disable Metrics/AbcSize,Metrics/MethodLength
  return nil if row.nil?

  new(
    ea_object_id: row["Object_ID"],
    name: row["Name"],
    scope: row["Scope"],
    stereotype: row["Stereotype"],
    containment: row["Containment"],
    isstatic: row["IsStatic"],
    iscollection: row["IsCollection"],
    isordered: row["IsOrdered"],
    allowduplicates: row["AllowDuplicates"],
    lowerbound: row["LowerBound"],
    upperbound: row["UpperBound"],
    container: row["Container"],
    notes: row["Notes"],
    derived: row["Derived"],
    id: row["ID"],
    pos: row["Pos"],
    genoption: row["GenOption"],
    length: row["Length"],
    precision: row["Precision"],
    scale: row["Scale"],
    const: row["Const"],
    style: row["Style"],
    classifier: row["Classifier"],
    default: row["Default"],
    type: row["Type"],
    ea_guid: row["ea_guid"],
    styleex: row["StyleEx"],
  )
end

.primary_key_columnObject



37
38
39
# File 'lib/lutaml/qea/models/ea_attribute.rb', line 37

def self.primary_key_column
  :id
end

.table_nameObject



41
42
43
# File 'lib/lutaml/qea/models/ea_attribute.rb', line 41

def self.table_name
  "t_attribute"
end

Instance Method Details

#allow_duplicates?Boolean

Check if attribute allows duplicates

Returns:

  • (Boolean)


103
104
105
# File 'lib/lutaml/qea/models/ea_attribute.rb', line 103

def allow_duplicates?
  allowduplicates == 1
end

#collection?Boolean

Check if attribute is a collection

Returns:

  • (Boolean)


91
92
93
# File 'lib/lutaml/qea/models/ea_attribute.rb', line 91

def collection?
  iscollection == 1
end

#constant?Boolean

Check if attribute is constant

Returns:

  • (Boolean)


109
110
111
# File 'lib/lutaml/qea/models/ea_attribute.rb', line 109

def constant?
  const == 1
end

#ordered?Boolean

Check if attribute is ordered

Returns:

  • (Boolean)


97
98
99
# File 'lib/lutaml/qea/models/ea_attribute.rb', line 97

def ordered?
  isordered == 1
end

#private?Boolean

Check if attribute is private

Returns:

  • (Boolean)


121
122
123
# File 'lib/lutaml/qea/models/ea_attribute.rb', line 121

def private?
  scope&.downcase == "private"
end

#protected?Boolean

Check if attribute is protected

Returns:

  • (Boolean)


127
128
129
# File 'lib/lutaml/qea/models/ea_attribute.rb', line 127

def protected?
  scope&.downcase == "protected"
end

#public?Boolean

Check if attribute is public

Returns:

  • (Boolean)


115
116
117
# File 'lib/lutaml/qea/models/ea_attribute.rb', line 115

def public?
  scope&.downcase == "public"
end

#static?Boolean

Check if attribute is static

Returns:

  • (Boolean)


85
86
87
# File 'lib/lutaml/qea/models/ea_attribute.rb', line 85

def static?
  isstatic == 1
end