Class: SObjectModel::Schema::Fields
- Inherits:
-
Object
- Object
- SObjectModel::Schema::Fields
- Includes:
- Enumerable
- Defined in:
- lib/sobject_model/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
260 261 262 |
# File 'lib/sobject_model/schema.rb', line 260 def each(&block) fields.each &block end |
#find_by(name: nil, label: nil) ⇒ Object
268 269 270 271 272 273 274 275 276 277 278 |
# File 'lib/sobject_model/schema.rb', line 268 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
288 289 290 |
# File 'lib/sobject_model/schema.rb', line 288 def labels map(&:label) end |
#name_and_labels ⇒ Object
280 281 282 |
# File 'lib/sobject_model/schema.rb', line 280 def name_and_labels map{|field| [field.name, field.label]} end |
#names ⇒ Object
284 285 286 |
# File 'lib/sobject_model/schema.rb', line 284 def names map(&:name) end |
#to_a ⇒ Object
264 265 266 |
# File 'lib/sobject_model/schema.rb', line 264 def to_a fields end |