Class: SfCli::Sf::Model::Schema
- Inherits:
-
Object
- Object
- SfCli::Sf::Model::Schema
- Defined in:
- lib/sf_cli/sf/model/schema.rb
Instance Attribute Summary collapse
-
#schema ⇒ Object
readonly
Returns the value of attribute schema.
Instance Method Summary collapse
- #children_relations ⇒ Object
- #field_names ⇒ Object
-
#initialize(schema) ⇒ Schema
constructor
A new instance of Schema.
- #name ⇒ Object
- #parent_relations ⇒ Object
Constructor Details
#initialize(schema) ⇒ Schema
Returns a new instance of Schema.
7 8 9 |
# File 'lib/sf_cli/sf/model/schema.rb', line 7 def initialize(schema) @schema = schema end |
Instance Attribute Details
#schema ⇒ Object (readonly)
Returns the value of attribute schema.
5 6 7 |
# File 'lib/sf_cli/sf/model/schema.rb', line 5 def schema @schema end |
Instance Method Details
#children_relations ⇒ Object
19 20 21 22 23 |
# File 'lib/sf_cli/sf/model/schema.rb', line 19 def children_relations schema['childRelationships'] .select{|r| r['relationshipName'].nil? == false} .map{|r| {name: r['relationshipName'].to_sym, class_name: r['childSObject'].to_sym}} end |
#field_names ⇒ Object
15 16 17 |
# File 'lib/sf_cli/sf/model/schema.rb', line 15 def field_names schema['fields'].map{|f| f['name'].to_sym} end |
#name ⇒ Object
11 12 13 |
# File 'lib/sf_cli/sf/model/schema.rb', line 11 def name schema['name'] end |
#parent_relations ⇒ Object
25 26 27 28 29 |
# File 'lib/sf_cli/sf/model/schema.rb', line 25 def parent_relations schema['fields'] .select{|f| f['relationshipName'].nil? == false && f['referenceTo']&.size > 0} .map{|f| {name: f['relationshipName'].to_sym, class_name: f['referenceTo'].first.to_sym}} end |