Class: SObjectModel::Schema
- Inherits:
-
Object
- Object
- SObjectModel::Schema
show all
- Defined in:
- lib/sobject_model/schema.rb
Overview
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_overrides ⇒ Object
54
55
56
|
# File 'lib/sobject_model/schema.rb', line 54
def action_overrides
schema["actionOverrides"]
end
|
#activateable? ⇒ Boolean
58
59
60
|
# File 'lib/sobject_model/schema.rb', line 58
def activateable?
schema["activateable"]
end
|
#associateEntityType ⇒ Object
62
63
64
|
# File 'lib/sobject_model/schema.rb', line 62
def associateEntityType
schema["associateEntityType"]
end
|
#associateParentEntity ⇒ Object
66
67
68
|
# File 'lib/sobject_model/schema.rb', line 66
def associateParentEntity
schema["associateParentEntity"]
end
|
#child_relations ⇒ Object
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
70
71
72
|
# File 'lib/sobject_model/schema.rb', line 70
def compact_layoutable?
schema["compactLayoutable"]
end
|
#createable? ⇒ Boolean
74
75
76
|
# File 'lib/sobject_model/schema.rb', line 74
def createable?
schema["createable"]
end
|
#custom? ⇒ Boolean
78
79
80
|
# File 'lib/sobject_model/schema.rb', line 78
def custom?
schema["custom"]
end
|
#custom_setting? ⇒ Boolean
82
83
84
|
# File 'lib/sobject_model/schema.rb', line 82
def custom_setting?
schema["customSetting"]
end
|
#deep_cloneable? ⇒ Boolean
86
87
88
|
# File 'lib/sobject_model/schema.rb', line 86
def deep_cloneable?
schema["deepCloneable"]
end
|
#default_implementation ⇒ Object
90
91
92
|
# File 'lib/sobject_model/schema.rb', line 90
def default_implementation
schema["defaultImplementation"]
end
|
#deletable? ⇒ Boolean
94
95
96
|
# File 'lib/sobject_model/schema.rb', line 94
def deletable?
schema["deletable"]
end
|
#deprecated_and_hidden? ⇒ Boolean
98
99
100
|
# File 'lib/sobject_model/schema.rb', line 98
def deprecated_and_hidden?
schema["deprecatedAndHidden"]
end
|
#extended_by ⇒ Object
102
103
104
|
# File 'lib/sobject_model/schema.rb', line 102
def extended_by
schema["extendedBy"]
end
|
#extends_interfaces ⇒ Object
106
107
108
|
# File 'lib/sobject_model/schema.rb', line 106
def extends_interfaces
schema["extendsInterfaces"]
end
|
#feed_enabled? ⇒ Boolean
110
111
112
|
# File 'lib/sobject_model/schema.rb', line 110
def feed_enabled?
schema["feedEnabled"]
end
|
#field_labels ⇒ Object
28
29
30
|
# File 'lib/sobject_model/schema.rb', line 28
def field_labels
@field_labels ||= fields.map{|f| f.label}.sort
end
|
#field_names ⇒ Object
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
|
#fields ⇒ Object
20
21
22
|
# File 'lib/sobject_model/schema.rb', line 20
def fields
@fields ||= Fields.new(schema)
end
|
#has_subtypes? ⇒ Boolean
114
115
116
|
# File 'lib/sobject_model/schema.rb', line 114
def has_subtypes?
schema["hasSubtypes"]
end
|
#implemented_by ⇒ Object
118
119
120
|
# File 'lib/sobject_model/schema.rb', line 118
def implemented_by
schema["implementedBy"]
end
|
#implements_interfaces ⇒ Object
122
123
124
|
# File 'lib/sobject_model/schema.rb', line 122
def implements_interfaces
schema["implementsInterfaces"]
end
|
#interface? ⇒ Boolean
126
127
128
|
# File 'lib/sobject_model/schema.rb', line 126
def interface?
schema["isInterface"]
end
|
#key_prefix ⇒ Object
134
135
136
|
# File 'lib/sobject_model/schema.rb', line 134
def key_prefix
schema["keyPrefix"]
end
|
#label ⇒ Object
16
17
18
|
# File 'lib/sobject_model/schema.rb', line 16
def label
@label = schema['label']
end
|
#label_plural ⇒ Object
138
139
140
|
# File 'lib/sobject_model/schema.rb', line 138
def label_plural
schema["labelPlural"]
end
|
#layoutable? ⇒ Boolean
142
143
144
|
# File 'lib/sobject_model/schema.rb', line 142
def layoutable?
schema["layoutable"]
end
|
#listviewable? ⇒ Boolean
146
147
148
|
# File 'lib/sobject_model/schema.rb', line 146
def listviewable?
schema["listviewable"]
end
|
#lookup_layoutable ⇒ Object
150
151
152
|
# File 'lib/sobject_model/schema.rb', line 150
def lookup_layoutable
schema["lookupLayoutable"]
end
|
#mergeable? ⇒ Boolean
154
155
156
|
# File 'lib/sobject_model/schema.rb', line 154
def mergeable?
schema["mergeable"]
end
|
#mruEnabled ⇒ Object
158
159
160
|
# File 'lib/sobject_model/schema.rb', line 158
def mruEnabled
schema["mruEnabled"]
end
|
#name ⇒ Object
12
13
14
|
# File 'lib/sobject_model/schema.rb', line 12
def name
@name = schema['name']
end
|
#named_layouts ⇒ Object
162
163
164
|
# File 'lib/sobject_model/schema.rb', line 162
def named_layouts
schema["namedLayoutInfos"]
end
|
#network_scope_field_name ⇒ Object
166
167
168
|
# File 'lib/sobject_model/schema.rb', line 166
def network_scope_field_name
schema["networkScopeFieldName"]
end
|
#parent_relations ⇒ Object
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
170
171
172
|
# File 'lib/sobject_model/schema.rb', line 170
def queryable?
schema["queryable"]
end
|
#record_types ⇒ Object
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_names ⇒ Object
46
47
48
|
# File 'lib/sobject_model/schema.rb', line 46
def relation_names
relations.names
end
|
#relations ⇒ Object
42
43
44
|
# File 'lib/sobject_model/schema.rb', line 42
def relations
@relations = Relations.new(child_relations + parent_relations)
end
|
#replicateable? ⇒ Boolean
178
179
180
|
# File 'lib/sobject_model/schema.rb', line 178
def replicateable?
schema["replicateable"]
end
|
#retrieveable? ⇒ Boolean
182
183
184
|
# File 'lib/sobject_model/schema.rb', line 182
def retrieveable?
schema["retrieveable"]
end
|
#search_layoutable? ⇒ Boolean
186
187
188
|
# File 'lib/sobject_model/schema.rb', line 186
def search_layoutable?
schema["searchLayoutable"]
end
|
#searchable? ⇒ Boolean
190
191
192
|
# File 'lib/sobject_model/schema.rb', line 190
def searchable?
schema["searchable"]
end
|
#sobject_describe_option ⇒ Object
194
195
196
|
# File 'lib/sobject_model/schema.rb', line 194
def sobject_describe_option
schema["sobjectDescribeOption"]
end
|
#subtype? ⇒ Boolean
130
131
132
|
# File 'lib/sobject_model/schema.rb', line 130
def subtype?
schema["isSubtype"]
end
|
#supported_scopes ⇒ Object
198
199
200
|
# File 'lib/sobject_model/schema.rb', line 198
def supported_scopes
schema["supportedScopes"]
end
|
#to_h ⇒ Object
50
51
52
|
# File 'lib/sobject_model/schema.rb', line 50
def to_h
schema
end
|
#triggerable? ⇒ Boolean
202
203
204
|
# File 'lib/sobject_model/schema.rb', line 202
def triggerable?
schema["triggerable"]
end
|
#undeletable? ⇒ Boolean
206
207
208
|
# File 'lib/sobject_model/schema.rb', line 206
def undeletable?
schema["undeletable"]
end
|
#updateable? ⇒ Boolean
210
211
212
|
# File 'lib/sobject_model/schema.rb', line 210
def updateable?
schema["updateable"]
end
|
#urls ⇒ Object
214
215
216
|
# File 'lib/sobject_model/schema.rb', line 214
def urls
schema["urls"]
end
|