Sha256: 1c0e75f6abad91f4927785d83e80d3489d11f99d47b50112529a22447c856184

Contents?: true

Size: 629 Bytes

Versions: 43

Compression:

Stored size: 629 Bytes

Contents

module WithExpectations
  extend ActiveSupport::Concern

  included do
    serialize :expectations, Array
    validate :ensure_expectations_format
  end

  def expectations_yaml
    self.expectations.to_yaml
  end

  def expectations_yaml=(yaml)
    self.expectations = YAML.load yaml
  end

  def expectations=(expectations)
    self[:expectations] = expectations.map(&:stringify_keys)
  end

  def raw_expectations
    self[:expectations]
  end

  def ensure_expectations_format
    errors.add :raw_expectations,
               :invalid_format unless raw_expectations.to_a.all? { |it| Mulang::Expectation.valid? it }
  end
end

Version data entries

43 entries across 43 versions & 1 rubygems

Version Path
mumuki-domain-9.23.0 app/models/concerns/with_expectations.rb
mumuki-domain-9.22.1 app/models/concerns/with_expectations.rb
mumuki-domain-9.22.0 app/models/concerns/with_expectations.rb
mumuki-domain-9.21.0 app/models/concerns/with_expectations.rb
mumuki-domain-9.20.0 app/models/concerns/with_expectations.rb
mumuki-domain-9.19.0 app/models/concerns/with_expectations.rb
mumuki-domain-9.18.0 app/models/concerns/with_expectations.rb
mumuki-domain-9.17.0 app/models/concerns/with_expectations.rb
mumuki-domain-9.16.0 app/models/concerns/with_expectations.rb
mumuki-domain-9.15.0 app/models/concerns/with_expectations.rb
mumuki-domain-9.14.1 app/models/concerns/with_expectations.rb
mumuki-domain-9.14.0 app/models/concerns/with_expectations.rb
mumuki-domain-9.13.1 app/models/concerns/with_expectations.rb
mumuki-domain-9.13.0 app/models/concerns/with_expectations.rb
mumuki-domain-9.12.0 app/models/concerns/with_expectations.rb
mumuki-domain-9.11.0 app/models/concerns/with_expectations.rb
mumuki-domain-9.10.0 app/models/concerns/with_expectations.rb
mumuki-domain-9.9.0 app/models/concerns/with_expectations.rb
mumuki-domain-9.8.1 app/models/concerns/with_expectations.rb
mumuki-domain-9.8.0 app/models/concerns/with_expectations.rb