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.
- #name_and_labels ⇒ Object
- #to_a ⇒ Object
Constructor Details
Instance Method Details
#each(&block) ⇒ Object
222 223 224 |
# File 'lib/sf_cli/sf/sobject/schema.rb', line 222 def each(&block) fields.each &block end |
#find_by(name: nil, label: nil) ⇒ Object
230 231 232 233 234 235 236 237 238 239 240 |
# File 'lib/sf_cli/sf/sobject/schema.rb', line 230 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 end end |
#name_and_labels ⇒ Object
242 243 244 |
# File 'lib/sf_cli/sf/sobject/schema.rb', line 242 def name_and_labels map{|field| [field.name, field.label]} end |
#to_a ⇒ Object
226 227 228 |
# File 'lib/sf_cli/sf/sobject/schema.rb', line 226 def to_a fields end |