Class: SfCli::Sf::Sobject::Schema::Fields
- Inherits:
-
Object
- Object
- SfCli::Sf::Sobject::Schema::Fields
- Includes:
- Enumerable
- Defined in:
- lib/sf_cli/sf/sobject/schema.rb
Instance Method Summary collapse
- #each(&block) ⇒ Object
- #find_by(name: nil, label: nil) ⇒ Object
-
#initialize(schema) ⇒ Fields
constructor
A new instance of Fields.
- #labels ⇒ Object
- #name_and_labels ⇒ Object
- #names ⇒ Object
- #to_a ⇒ Object
Constructor Details
Instance Method Details
#each(&block) ⇒ Object
262 263 264 |
# File 'lib/sf_cli/sf/sobject/schema.rb', line 262 def each(&block) fields.each &block end |
#find_by(name: nil, label: nil) ⇒ Object
270 271 272 273 274 275 276 277 278 279 280 |
# File 'lib/sf_cli/sf/sobject/schema.rb', line 270 def find_by(name: nil, label: nil) return nil if name.nil? && label.nil? attr_name = name.nil? ? :label : :name val = name || label find do |field| attr_val = field.__send__(attr_name.to_sym) attr_val == val.to_s end end |
#labels ⇒ Object
290 291 292 |
# File 'lib/sf_cli/sf/sobject/schema.rb', line 290 def labels map(&:label) end |
#name_and_labels ⇒ Object
282 283 284 |
# File 'lib/sf_cli/sf/sobject/schema.rb', line 282 def name_and_labels map{|field| [field.name, field.label]} end |
#names ⇒ Object
286 287 288 |
# File 'lib/sf_cli/sf/sobject/schema.rb', line 286 def names map(&:name) end |
#to_a ⇒ Object
266 267 268 |
# File 'lib/sf_cli/sf/sobject/schema.rb', line 266 def to_a fields end |