Class: SfCli::Sf::Sobject::Schema
  
  
  
  
  
    - Inherits:
 
    - 
      Object
      
        
          - Object
 
          
            - SfCli::Sf::Sobject::Schema
 
          
        
        show all
      
     
  
  
  
  
  
  
  
  
  
  
    - Defined in:
 
    - lib/sf_cli/sf/sobject/schema.rb
 
  
  
 
Defined Under Namespace
  
    
  
    
      Classes: Field, Fields, RecordType, Relation, Relations
    
  
  
    
      Instance Method Summary
      collapse
    
    
  
  Constructor Details
  
    
  
  
    #initialize(schema)  ⇒ Schema 
  
  
  
  
    
Returns a new instance of Schema.
   
 
  
  
    
      
5
6
7 
     | 
    
      # File 'lib/sf_cli/sf/sobject/schema.rb', line 5
def initialize(schema)
  @schema = schema
end 
     | 
  
 
  
 
  
    Instance Method Details
    
      
  
  
    #action_overrides  ⇒ Object 
  
  
  
  
    
      
55
56
57 
     | 
    
      # File 'lib/sf_cli/sf/sobject/schema.rb', line 55
def action_overrides
  schema["actionOverrides"]
end 
     | 
  
 
    
      
  
  
    #activateable?  ⇒ Boolean 
  
  
  
  
    
      
59
60
61 
     | 
    
      # File 'lib/sf_cli/sf/sobject/schema.rb', line 59
def activateable?
  schema["activateable"]
end 
     | 
  
 
    
      
  
  
    #associateEntityType  ⇒ Object 
  
  
  
  
    
      
63
64
65 
     | 
    
      # File 'lib/sf_cli/sf/sobject/schema.rb', line 63
def associateEntityType
  schema["associateEntityType"]
end 
     | 
  
 
    
      
  
  
    #associateParentEntity  ⇒ Object 
  
  
  
  
    
      
67
68
69 
     | 
    
      # File 'lib/sf_cli/sf/sobject/schema.rb', line 67
def associateParentEntity
  schema["associateParentEntity"]
end 
     | 
  
 
    
      
  
  
    #children_relations  ⇒ Object 
  
  
  
  
    
      
29
30
31
32
33
34 
     | 
    
      # File 'lib/sf_cli/sf/sobject/schema.rb', line 29
def children_relations
  @children_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 
  
  
  
  
    
      
71
72
73 
     | 
    
      # File 'lib/sf_cli/sf/sobject/schema.rb', line 71
def compact_layoutable?
  schema["compactLayoutable"]
end 
     | 
  
 
    
      
  
  
    #createable?  ⇒ Boolean 
  
  
  
  
    
      
75
76
77 
     | 
    
      # File 'lib/sf_cli/sf/sobject/schema.rb', line 75
def createable?
  schema["createable"]
end 
     | 
  
 
    
      
  
  
    #custom?  ⇒ Boolean 
  
  
  
  
    
      
79
80
81 
     | 
    
      # File 'lib/sf_cli/sf/sobject/schema.rb', line 79
def custom?
  schema["custom"]
end 
     | 
  
 
    
      
  
  
    #custom_setting?  ⇒ Boolean 
  
  
  
  
    
      
83
84
85 
     | 
    
      # File 'lib/sf_cli/sf/sobject/schema.rb', line 83
def custom_setting?
  schema["customSetting"]
end 
     | 
  
 
    
      
  
  
    #deep_cloneable?  ⇒ Boolean 
  
  
  
  
    
      
87
88
89 
     | 
    
      # File 'lib/sf_cli/sf/sobject/schema.rb', line 87
def deep_cloneable?
  schema["deepCloneable"]
end 
     | 
  
 
    
      
  
  
    #default_implementation  ⇒ Object 
  
  
  
  
    
      
91
92
93 
     | 
    
      # File 'lib/sf_cli/sf/sobject/schema.rb', line 91
def default_implementation
  schema["defaultImplementation"]
end 
     | 
  
 
    
      
  
  
    #deletable?  ⇒ Boolean 
  
  
  
  
    
      
95
96
97 
     | 
    
      # File 'lib/sf_cli/sf/sobject/schema.rb', line 95
def deletable?
  schema["deletable"]
end 
     | 
  
 
    
      
  
  
    #deprecated_and_hidden?  ⇒ Boolean 
  
  
  
  
    
      
99
100
101 
     | 
    
      # File 'lib/sf_cli/sf/sobject/schema.rb', line 99
def deprecated_and_hidden?
  schema["deprecatedAndHidden"]
end 
     | 
  
 
    
      
  
  
    #extended_by  ⇒ Object 
  
  
  
  
    
      
103
104
105 
     | 
    
      # File 'lib/sf_cli/sf/sobject/schema.rb', line 103
def extended_by
  schema["extendedBy"]
end 
     | 
  
 
    
      
  
  
    #extends_interfaces  ⇒ Object 
  
  
  
  
    
      
107
108
109 
     | 
    
      # File 'lib/sf_cli/sf/sobject/schema.rb', line 107
def extends_interfaces
  schema["extendsInterfaces"]
end 
     | 
  
 
    
      
  
  
    #feed_enabled?  ⇒ Boolean 
  
  
  
  
    
      
111
112
113 
     | 
    
      # File 'lib/sf_cli/sf/sobject/schema.rb', line 111
def feed_enabled?
  schema["feedEnabled"]
end 
     | 
  
 
    
      
  
  
    #field_labels  ⇒ Object 
  
  
  
  
    
      
25
26
27 
     | 
    
      # File 'lib/sf_cli/sf/sobject/schema.rb', line 25
def field_labels
  @field_labels ||= fields.map{|f| f.label}.sort
end
     | 
  
 
    
      
  
  
    #field_names  ⇒ Object 
  
  
  
  
    
      
21
22
23 
     | 
    
      # File 'lib/sf_cli/sf/sobject/schema.rb', line 21
def field_names
  @field_names ||= fields.map{|f| f.name.to_sym}.sort
end
     | 
  
 
    
      
  
  
    #fields  ⇒ Object 
  
  
  
  
    
      
17
18
19 
     | 
    
      # File 'lib/sf_cli/sf/sobject/schema.rb', line 17
def fields
  @fields ||= Fields.new(schema)
end 
     | 
  
 
    
      
  
  
    #has_subtypes?  ⇒ Boolean 
  
  
  
  
    
      
115
116
117 
     | 
    
      # File 'lib/sf_cli/sf/sobject/schema.rb', line 115
def has_subtypes?
  schema["hasSubtypes"]
end 
     | 
  
 
    
      
  
  
    #implemented_by  ⇒ Object 
  
  
  
  
    
      
119
120
121 
     | 
    
      # File 'lib/sf_cli/sf/sobject/schema.rb', line 119
def implemented_by
  schema["implementedBy"]
end 
     | 
  
 
    
      
  
  
    #implements_interfaces  ⇒ Object 
  
  
  
  
    
      
123
124
125 
     | 
    
      # File 'lib/sf_cli/sf/sobject/schema.rb', line 123
def implements_interfaces
  schema["implementsInterfaces"]
end 
     | 
  
 
    
      
  
  
    #interface?  ⇒ Boolean 
  
  
  
  
    
      
127
128
129 
     | 
    
      # File 'lib/sf_cli/sf/sobject/schema.rb', line 127
def interface?
  schema["isInterface"]
end 
     | 
  
 
    
      
  
  
    #key_prefix  ⇒ Object 
  
  
  
  
    
      
135
136
137 
     | 
    
      # File 'lib/sf_cli/sf/sobject/schema.rb', line 135
def key_prefix
  schema["keyPrefix"]
end 
     | 
  
 
    
      
  
  
    #label  ⇒ Object 
  
  
  
  
    
      
13
14
15 
     | 
    
      # File 'lib/sf_cli/sf/sobject/schema.rb', line 13
def label
  schema['label']
end 
     | 
  
 
    
      
  
  
    #label_plural  ⇒ Object 
  
  
  
  
    
      
139
140
141 
     | 
    
      # File 'lib/sf_cli/sf/sobject/schema.rb', line 139
def label_plural
  schema["labelPlural"]
end 
     | 
  
 
    
      
  
  
    #layoutable?  ⇒ Boolean 
  
  
  
  
    
      
143
144
145 
     | 
    
      # File 'lib/sf_cli/sf/sobject/schema.rb', line 143
def layoutable?
  schema["layoutable"]
end 
     | 
  
 
    
      
  
  
    #listviewable?  ⇒ Boolean 
  
  
  
  
    
      
147
148
149 
     | 
    
      # File 'lib/sf_cli/sf/sobject/schema.rb', line 147
def listviewable?
  schema["listviewable"]
end 
     | 
  
 
    
      
  
  
    #lookup_layoutable  ⇒ Object 
  
  
  
  
    
      
151
152
153 
     | 
    
      # File 'lib/sf_cli/sf/sobject/schema.rb', line 151
def lookup_layoutable
  schema["lookupLayoutable"]
end 
     | 
  
 
    
      
  
  
    #mergeable?  ⇒ Boolean 
  
  
  
  
    
      
155
156
157 
     | 
    
      # File 'lib/sf_cli/sf/sobject/schema.rb', line 155
def mergeable?
  schema["mergeable"]
end 
     | 
  
 
    
      
  
  
    #mruEnabled  ⇒ Object 
  
  
  
  
    
      
159
160
161 
     | 
    
      # File 'lib/sf_cli/sf/sobject/schema.rb', line 159
def mruEnabled
  schema["mruEnabled"]
end 
     | 
  
 
    
      
  
  
    #name  ⇒ Object 
  
  
  
  
    
      
9
10
11 
     | 
    
      # File 'lib/sf_cli/sf/sobject/schema.rb', line 9
def name
  schema['name']
end 
     | 
  
 
    
      
  
  
    #named_layouts  ⇒ Object 
  
  
  
  
    
      
163
164
165 
     | 
    
      # File 'lib/sf_cli/sf/sobject/schema.rb', line 163
def named_layouts
  schema["namedLayoutInfos"]
end 
     | 
  
 
    
      
  
  
    #network_scope_field_name  ⇒ Object 
  
  
  
  
    
      
167
168
169 
     | 
    
      # File 'lib/sf_cli/sf/sobject/schema.rb', line 167
def network_scope_field_name
  schema["networkScopeFieldName"]
end 
     | 
  
 
    
      
  
  
    #parent_relations  ⇒ Object 
  
  
  
  
    
      
36
37
38
39
40
41 
     | 
    
      # File 'lib/sf_cli/sf/sobject/schema.rb', line 36
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 
  
  
  
  
    
      
171
172
173 
     | 
    
      # File 'lib/sf_cli/sf/sobject/schema.rb', line 171
def queryable?
  schema["queryable"]
end 
     | 
  
 
    
      
  
  
    #record_types  ⇒ Object 
  
  
  
  
    
      
175
176
177 
     | 
    
      # File 'lib/sf_cli/sf/sobject/schema.rb', line 175
def record_types
  @record_types = schema["recordTypeInfos"].map{|rt| RecordType.new(**rt)}
end
     | 
  
 
    
      
  
  
    #relation_names  ⇒ Object 
  
  
  
  
    
      
47
48
49 
     | 
    
      # File 'lib/sf_cli/sf/sobject/schema.rb', line 47
def relation_names
  relations.names
end 
     | 
  
 
    
      
  
  
    #relations  ⇒ Object 
  
  
  
  
    
      
43
44
45 
     | 
    
      # File 'lib/sf_cli/sf/sobject/schema.rb', line 43
def relations
  @relations ||= Relations.new(children_relations + parent_relations)
end 
     | 
  
 
    
      
  
  
    #replicateable?  ⇒ Boolean 
  
  
  
  
    
      
179
180
181 
     | 
    
      # File 'lib/sf_cli/sf/sobject/schema.rb', line 179
def replicateable?
  schema["replicateable"]
end 
     | 
  
 
    
      
  
  
    #retrieveable?  ⇒ Boolean 
  
  
  
  
    
      
183
184
185 
     | 
    
      # File 'lib/sf_cli/sf/sobject/schema.rb', line 183
def retrieveable?
  schema["retrieveable"]
end 
     | 
  
 
    
      
  
  
    #search_layoutable?  ⇒ Boolean 
  
  
  
  
    
      
187
188
189 
     | 
    
      # File 'lib/sf_cli/sf/sobject/schema.rb', line 187
def search_layoutable?
  schema["searchLayoutable"]
end 
     | 
  
 
    
      
  
  
    #searchable?  ⇒ Boolean 
  
  
  
  
    
      
191
192
193 
     | 
    
      # File 'lib/sf_cli/sf/sobject/schema.rb', line 191
def searchable?
  schema["searchable"]
end 
     | 
  
 
    
      
  
  
    #sobject_describe_option  ⇒ Object 
  
  
  
  
    
      
195
196
197 
     | 
    
      # File 'lib/sf_cli/sf/sobject/schema.rb', line 195
def sobject_describe_option
  schema["sobjectDescribeOption"]
end 
     | 
  
 
    
      
  
  
    #subtype?  ⇒ Boolean 
  
  
  
  
    
      
131
132
133 
     | 
    
      # File 'lib/sf_cli/sf/sobject/schema.rb', line 131
def subtype?
  schema["isSubtype"]
end 
     | 
  
 
    
      
  
  
    #supported_scopes  ⇒ Object 
  
  
  
  
    
      
199
200
201 
     | 
    
      # File 'lib/sf_cli/sf/sobject/schema.rb', line 199
def supported_scopes
  schema["supportedScopes"]
end 
     | 
  
 
    
      
  
  
    #to_h  ⇒ Object 
  
  
  
  
    
      
51
52
53 
     | 
    
      # File 'lib/sf_cli/sf/sobject/schema.rb', line 51
def to_h
  schema
end 
     | 
  
 
    
      
  
  
    #triggerable?  ⇒ Boolean 
  
  
  
  
    
      
203
204
205 
     | 
    
      # File 'lib/sf_cli/sf/sobject/schema.rb', line 203
def triggerable?
  schema["triggerable"]
end 
     | 
  
 
    
      
  
  
    #undeletable?  ⇒ Boolean 
  
  
  
  
    
      
207
208
209 
     | 
    
      # File 'lib/sf_cli/sf/sobject/schema.rb', line 207
def undeletable?
  schema["undeletable"]
end 
     | 
  
 
    
      
  
  
    #updateable?  ⇒ Boolean 
  
  
  
  
    
      
211
212
213 
     | 
    
      # File 'lib/sf_cli/sf/sobject/schema.rb', line 211
def updateable?
  schema["updateable"]
end 
     | 
  
 
    
      
  
  
    #urls  ⇒ Object 
  
  
  
  
    
      
215
216
217 
     | 
    
      # File 'lib/sf_cli/sf/sobject/schema.rb', line 215
def urls
  schema["urls"]
end 
     |