Class: Remi::BusinessRules::DataField

Inherits:
Object
  • Object
show all
Defined in:
lib/remi/cucumber/business_rules.rb

Instance Method Summary collapse

Constructor Details

#initialize(subject, field_name) ⇒ DataField

Returns a new instance of DataField.



412
413
414
415
# File 'lib/remi/cucumber/business_rules.rb', line 412

def initialize(subject, field_name)
  @subject = subject
  @field_name = field_name.symbolize(subject.field_symbolizer)
end

Instance Method Details

#metadataObject



421
422
423
# File 'lib/remi/cucumber/business_rules.rb', line 421

def 
  @subject.fields[name]
end

#nameObject



417
418
419
# File 'lib/remi/cucumber/business_rules.rb', line 417

def name
  @field_name
end

#valueObject



429
430
431
432
433
# File 'lib/remi/cucumber/business_rules.rb', line 429

def value
  v = vector.to_a.uniq
  raise "Multiple unique values found in subject data for field #{@field_name}" if v.size > 1
  v.first
end

#value=(arg) ⇒ Object



439
440
441
# File 'lib/remi/cucumber/business_rules.rb', line 439

def value=(arg)
  vector.recode! { |v| arg }
end

#valuesObject



435
436
437
# File 'lib/remi/cucumber/business_rules.rb', line 435

def values
  vector.to_a.map(&:to_s)
end

#vectorObject



425
426
427
# File 'lib/remi/cucumber/business_rules.rb', line 425

def vector
  @subject.df[@field_name]
end