Class: Remi::BusinessRules::DataField
- Inherits:
-
Object
- Object
- Remi::BusinessRules::DataField
- Defined in:
- lib/remi/cucumber/business_rules.rb
Instance Method Summary collapse
-
#initialize(subject, field_name) ⇒ DataField
constructor
A new instance of DataField.
- #metadata ⇒ Object
- #name ⇒ Object
- #value ⇒ Object
- #value=(arg) ⇒ Object
- #values ⇒ Object
- #vector ⇒ Object
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
#metadata ⇒ Object
421 422 423 |
# File 'lib/remi/cucumber/business_rules.rb', line 421 def @subject.fields[name] end |
#name ⇒ Object
417 418 419 |
# File 'lib/remi/cucumber/business_rules.rb', line 417 def name @field_name end |
#value ⇒ Object
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 |
#values ⇒ Object
435 436 437 |
# File 'lib/remi/cucumber/business_rules.rb', line 435 def values vector.to_a.map(&:to_s) end |
#vector ⇒ Object
425 426 427 |
# File 'lib/remi/cucumber/business_rules.rb', line 425 def vector @subject.df[@field_name] end |