Class: Remi::Testing::BusinessRules::DataField
- Inherits:
-
Object
- Object
- Remi::Testing::BusinessRules::DataField
- Defined in:
- lib/remi/testing/business_rules.rb
Instance Attribute Summary collapse
-
#field_name ⇒ Object
readonly
Returns the value of attribute field_name.
-
#name ⇒ Object
readonly
Returns the value of attribute name.
-
#subject ⇒ Object
readonly
Returns the value of attribute subject.
Instance Method Summary collapse
- #full_name ⇒ Object
-
#initialize(subject, name) ⇒ DataField
constructor
A new instance of DataField.
- #metadata ⇒ Object
- #value ⇒ Object
- #value=(arg) ⇒ Object
- #values ⇒ Object
- #vector ⇒ Object
Constructor Details
#initialize(subject, name) ⇒ DataField
Returns a new instance of DataField.
456 457 458 459 460 |
# File 'lib/remi/testing/business_rules.rb', line 456 def initialize(subject, name) @subject = subject @name = name @field_name = name.symbolize(subject.data_subject.field_symbolizer) end |
Instance Attribute Details
#field_name ⇒ Object (readonly)
Returns the value of attribute field_name.
463 464 465 |
# File 'lib/remi/testing/business_rules.rb', line 463 def field_name @field_name end |
#name ⇒ Object (readonly)
Returns the value of attribute name.
462 463 464 |
# File 'lib/remi/testing/business_rules.rb', line 462 def name @name end |
#subject ⇒ Object (readonly)
Returns the value of attribute subject.
464 465 466 |
# File 'lib/remi/testing/business_rules.rb', line 464 def subject @subject end |
Instance Method Details
#full_name ⇒ Object
466 467 468 |
# File 'lib/remi/testing/business_rules.rb', line 466 def full_name "#{@subject.name}: #{@name}" end |
#metadata ⇒ Object
470 471 472 |
# File 'lib/remi/testing/business_rules.rb', line 470 def @subject.data_subject.fields[@field_name] end |
#value ⇒ Object
478 479 480 481 482 |
# File 'lib/remi/testing/business_rules.rb', line 478 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
488 489 490 491 492 493 494 495 496 |
# File 'lib/remi/testing/business_rules.rb', line 488 def value=(arg) typed_arg = if [:type] == :json JSON.parse(arg) else arg end vector.recode! { |_v| typed_arg } end |
#values ⇒ Object
484 485 486 |
# File 'lib/remi/testing/business_rules.rb', line 484 def values vector.to_a.map(&:to_s) end |
#vector ⇒ Object
474 475 476 |
# File 'lib/remi/testing/business_rules.rb', line 474 def vector @subject.data_subject.df[@field_name] end |