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.
467 468 469 470 471 |
# File 'lib/remi/testing/business_rules.rb', line 467 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.
474 475 476 |
# File 'lib/remi/testing/business_rules.rb', line 474 def field_name @field_name end |
#name ⇒ Object (readonly)
Returns the value of attribute name.
473 474 475 |
# File 'lib/remi/testing/business_rules.rb', line 473 def name @name end |
#subject ⇒ Object (readonly)
Returns the value of attribute subject.
475 476 477 |
# File 'lib/remi/testing/business_rules.rb', line 475 def subject @subject end |
Instance Method Details
#full_name ⇒ Object
477 478 479 |
# File 'lib/remi/testing/business_rules.rb', line 477 def full_name "#{@subject.name}: #{@name}" end |
#metadata ⇒ Object
481 482 483 |
# File 'lib/remi/testing/business_rules.rb', line 481 def @subject.data_subject.fields[@field_name] end |
#value ⇒ Object
489 490 491 492 493 |
# File 'lib/remi/testing/business_rules.rb', line 489 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
499 500 501 502 503 504 505 506 507 |
# File 'lib/remi/testing/business_rules.rb', line 499 def value=(arg) typed_arg = if [:type] == :json JSON.parse(arg) else arg end vector.recode! { |_v| typed_arg } end |
#values ⇒ Object
495 496 497 |
# File 'lib/remi/testing/business_rules.rb', line 495 def values vector.to_a.map(&:to_s) end |
#vector ⇒ Object
485 486 487 |
# File 'lib/remi/testing/business_rules.rb', line 485 def vector @subject.data_subject.df[@field_name] end |