Class: SObjectModel::Schema

Inherits:
Object
  • Object
show all
Defined in:
lib/sobject_model/schema.rb

Overview

sObject Schema

Defined Under Namespace

Classes: Field, Fields, RecordType, Relation, Relations

Instance Method Summary collapse

Constructor Details

#initialize(schema_hash) ⇒ Schema

Returns a new instance of Schema.



8
9
10
# File 'lib/sobject_model/schema.rb', line 8

def initialize(schema_hash)
  @schema = schema_hash
end

Instance Method Details

#action_overridesObject



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

def action_overrides
  schema["actionOverrides"]
end

#activateable?Boolean

Returns:

  • (Boolean)


58
59
60
# File 'lib/sobject_model/schema.rb', line 58

def activateable?
  schema["activateable"]
end

#associateEntityTypeObject



62
63
64
# File 'lib/sobject_model/schema.rb', line 62

def associateEntityType
  schema["associateEntityType"]
end

#associateParentEntityObject



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

def associateParentEntity
  schema["associateParentEntity"]
end

#child_relationsObject



32
33
34
35
# File 'lib/sobject_model/schema.rb', line 32

def child_relations
 @child_relations ||= schema['childRelationships'].select{|r| r['relationshipName'].nil? == false}
                        .map{|r| {name: r['relationshipName'].to_sym, field: r['field'].to_sym, class_name: r['childSObject'].to_sym}}
end

#compact_layoutable?Boolean

Returns:

  • (Boolean)


70
71
72
# File 'lib/sobject_model/schema.rb', line 70

def compact_layoutable?
  schema["compactLayoutable"]
end

#createable?Boolean

Returns:

  • (Boolean)


74
75
76
# File 'lib/sobject_model/schema.rb', line 74

def createable?
  schema["createable"]
end

#custom?Boolean

Returns:

  • (Boolean)


78
79
80
# File 'lib/sobject_model/schema.rb', line 78

def custom?
  schema["custom"]
end

#custom_setting?Boolean

Returns:

  • (Boolean)


82
83
84
# File 'lib/sobject_model/schema.rb', line 82

def custom_setting?
  schema["customSetting"]
end

#deep_cloneable?Boolean

Returns:

  • (Boolean)


86
87
88
# File 'lib/sobject_model/schema.rb', line 86

def deep_cloneable?
  schema["deepCloneable"]
end

#default_implementationObject



90
91
92
# File 'lib/sobject_model/schema.rb', line 90

def default_implementation
  schema["defaultImplementation"]
end

#deletable?Boolean

Returns:

  • (Boolean)


94
95
96
# File 'lib/sobject_model/schema.rb', line 94

def deletable?
  schema["deletable"]
end

#deprecated_and_hidden?Boolean

Returns:

  • (Boolean)


98
99
100
# File 'lib/sobject_model/schema.rb', line 98

def deprecated_and_hidden?
  schema["deprecatedAndHidden"]
end

#extended_byObject



102
103
104
# File 'lib/sobject_model/schema.rb', line 102

def extended_by
  schema["extendedBy"]
end

#extends_interfacesObject



106
107
108
# File 'lib/sobject_model/schema.rb', line 106

def extends_interfaces
  schema["extendsInterfaces"]
end

#feed_enabled?Boolean

Returns:

  • (Boolean)


110
111
112
# File 'lib/sobject_model/schema.rb', line 110

def feed_enabled?
  schema["feedEnabled"]
end

#field_labelsObject



28
29
30
# File 'lib/sobject_model/schema.rb', line 28

def field_labels
  @field_labels ||= fields.map{|f| f.label}.sort
end

#field_namesObject



24
25
26
# File 'lib/sobject_model/schema.rb', line 24

def field_names
  @field_names ||= fields.map{|f| f.name.to_sym}.sort
end

#fieldsObject



20
21
22
# File 'lib/sobject_model/schema.rb', line 20

def fields
  @fields ||= Fields.new(schema)
end

#has_subtypes?Boolean

Returns:

  • (Boolean)


114
115
116
# File 'lib/sobject_model/schema.rb', line 114

def has_subtypes?
  schema["hasSubtypes"]
end

#implemented_byObject



118
119
120
# File 'lib/sobject_model/schema.rb', line 118

def implemented_by
  schema["implementedBy"]
end

#implements_interfacesObject



122
123
124
# File 'lib/sobject_model/schema.rb', line 122

def implements_interfaces
  schema["implementsInterfaces"]
end

#interface?Boolean

Returns:

  • (Boolean)


126
127
128
# File 'lib/sobject_model/schema.rb', line 126

def interface?
  schema["isInterface"]
end

#key_prefixObject



134
135
136
# File 'lib/sobject_model/schema.rb', line 134

def key_prefix
  schema["keyPrefix"]
end

#labelObject



16
17
18
# File 'lib/sobject_model/schema.rb', line 16

def label
  @label = schema['label']
end

#label_pluralObject



138
139
140
# File 'lib/sobject_model/schema.rb', line 138

def label_plural
  schema["labelPlural"]
end

#layoutable?Boolean

Returns:

  • (Boolean)


142
143
144
# File 'lib/sobject_model/schema.rb', line 142

def layoutable?
  schema["layoutable"]
end

#listviewable?Boolean

Returns:

  • (Boolean)


146
147
148
# File 'lib/sobject_model/schema.rb', line 146

def listviewable?
  schema["listviewable"]
end

#lookup_layoutableObject



150
151
152
# File 'lib/sobject_model/schema.rb', line 150

def lookup_layoutable
  schema["lookupLayoutable"]
end

#mergeable?Boolean

Returns:

  • (Boolean)


154
155
156
# File 'lib/sobject_model/schema.rb', line 154

def mergeable?
  schema["mergeable"]
end

#mruEnabledObject



158
159
160
# File 'lib/sobject_model/schema.rb', line 158

def mruEnabled
  schema["mruEnabled"]
end

#nameObject



12
13
14
# File 'lib/sobject_model/schema.rb', line 12

def name
  @name = schema['name']
end

#named_layoutsObject



162
163
164
# File 'lib/sobject_model/schema.rb', line 162

def named_layouts
  schema["namedLayoutInfos"]
end

#network_scope_field_nameObject



166
167
168
# File 'lib/sobject_model/schema.rb', line 166

def network_scope_field_name
  schema["networkScopeFieldName"]
end

#parent_relationsObject



37
38
39
40
# File 'lib/sobject_model/schema.rb', line 37

def parent_relations
  @parent_relations ||= fields.select{|f| !(f.relationship_name.nil? || f.reference_to.nil?) && f.reference_to.size > 0}
                          .map{|f| {name: f.relationship_name.to_sym, field: f.name.to_sym, class_name: f.reference_to.first.to_sym} }
end

#queryable?Boolean

Returns:

  • (Boolean)


170
171
172
# File 'lib/sobject_model/schema.rb', line 170

def queryable?
  schema["queryable"]
end

#record_typesObject



174
175
176
# File 'lib/sobject_model/schema.rb', line 174

def record_types
  @record_types = schema["recordTypeInfos"].map{|rt| RecordType.new(**rt)}
end

#relation_namesObject



46
47
48
# File 'lib/sobject_model/schema.rb', line 46

def relation_names
  relations.names
end

#relationsObject



42
43
44
# File 'lib/sobject_model/schema.rb', line 42

def relations
  @relations = Relations.new(child_relations + parent_relations)
end

#replicateable?Boolean

Returns:

  • (Boolean)


178
179
180
# File 'lib/sobject_model/schema.rb', line 178

def replicateable?
  schema["replicateable"]
end

#retrieveable?Boolean

Returns:

  • (Boolean)


182
183
184
# File 'lib/sobject_model/schema.rb', line 182

def retrieveable?
  schema["retrieveable"]
end

#search_layoutable?Boolean

Returns:

  • (Boolean)


186
187
188
# File 'lib/sobject_model/schema.rb', line 186

def search_layoutable?
  schema["searchLayoutable"]
end

#searchable?Boolean

Returns:

  • (Boolean)


190
191
192
# File 'lib/sobject_model/schema.rb', line 190

def searchable?
  schema["searchable"]
end

#sobject_describe_optionObject



194
195
196
# File 'lib/sobject_model/schema.rb', line 194

def sobject_describe_option
  schema["sobjectDescribeOption"]
end

#subtype?Boolean

Returns:

  • (Boolean)


130
131
132
# File 'lib/sobject_model/schema.rb', line 130

def subtype?
  schema["isSubtype"]
end

#supported_scopesObject



198
199
200
# File 'lib/sobject_model/schema.rb', line 198

def supported_scopes
  schema["supportedScopes"]
end

#to_hObject



50
51
52
# File 'lib/sobject_model/schema.rb', line 50

def to_h
  schema
end

#triggerable?Boolean

Returns:

  • (Boolean)


202
203
204
# File 'lib/sobject_model/schema.rb', line 202

def triggerable?
  schema["triggerable"]
end

#undeletable?Boolean

Returns:

  • (Boolean)


206
207
208
# File 'lib/sobject_model/schema.rb', line 206

def undeletable?
  schema["undeletable"]
end

#updateable?Boolean

Returns:

  • (Boolean)


210
211
212
# File 'lib/sobject_model/schema.rb', line 210

def updateable?
  schema["updateable"]
end

#urlsObject



214
215
216
# File 'lib/sobject_model/schema.rb', line 214

def urls
  schema["urls"]
end