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
- #own_custom_expectations ⇒ Object
- #own_expectations ⇒ Object
Instance Method Details
#ensure_expectations_format ⇒ Object
29 30 31 32 |
# File 'app/models/concerns/with_expectations.rb', line 29 def ensure_expectations_format errors.add :own_expectations, :invalid_format unless own_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 |
#own_custom_expectations ⇒ Object
25 26 27 |
# File 'app/models/concerns/with_expectations.rb', line 25 def own_custom_expectations self[:custom_expectations] end |
#own_expectations ⇒ Object
21 22 23 |
# File 'app/models/concerns/with_expectations.rb', line 21 def own_expectations self[:expectations] end |