Module: WithExpectations
- Extended by:
- ActiveSupport::Concern
- Defined in:
- app/models/concerns/with_expectations.rb
Instance Method Summary collapse
- #ensure_expectations_format ⇒ Object
- #expectations=(expectations) ⇒ Object
- #expectations_yaml ⇒ Object
- #expectations_yaml=(yaml) ⇒ Object
- #raw_expectations ⇒ Object
Instance Method Details
#ensure_expectations_format ⇒ Object
25 26 27 28 |
# File 'app/models/concerns/with_expectations.rb', line 25 def ensure_expectations_format errors.add :raw_expectations, :invalid_format unless raw_expectations.to_a.all? { |it| Mulang::Expectation.valid? it } end |
#expectations=(expectations) ⇒ Object
17 18 19 |
# File 'app/models/concerns/with_expectations.rb', line 17 def expectations=(expectations) self[:expectations] = expectations.map(&:stringify_keys) end |
#expectations_yaml ⇒ Object
9 10 11 |
# File 'app/models/concerns/with_expectations.rb', line 9 def expectations_yaml self.expectations.to_yaml end |
#expectations_yaml=(yaml) ⇒ Object
13 14 15 |
# File 'app/models/concerns/with_expectations.rb', line 13 def expectations_yaml=(yaml) self.expectations = YAML.load yaml end |
#raw_expectations ⇒ Object
21 22 23 |
# File 'app/models/concerns/with_expectations.rb', line 21 def raw_expectations self[:expectations] end |