Sha256: 96d6ffe8789e33d87a79e2f55751f3892c80a2131fbee27dc464e5ed12b80572

Contents?: true

Size: 630 Bytes

Versions: 26

Compression:

Stored size: 630 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 own_expectations
    self[:expectations]
  end

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

Version data entries

26 entries across 26 versions & 1 rubygems

Version Path
mumuki-domain-7.0.1 app/models/concerns/with_expectations.rb
mumuki-domain-7.0.0 app/models/concerns/with_expectations.rb
mumuki-domain-6.7.2 app/models/concerns/with_expectations.rb
mumuki-domain-6.7.1 app/models/concerns/with_expectations.rb
mumuki-domain-6.7.0 app/models/concerns/with_expectations.rb
mumuki-domain-6.6.2 app/models/concerns/with_expectations.rb
mumuki-domain-6.6.1 app/models/concerns/with_expectations.rb
mumuki-domain-6.6.0 app/models/concerns/with_expectations.rb
mumuki-domain-6.5.1 app/models/concerns/with_expectations.rb
mumuki-domain-6.5.0 app/models/concerns/with_expectations.rb
mumuki-domain-6.4.3 app/models/concerns/with_expectations.rb
mumuki-domain-6.4.2 app/models/concerns/with_expectations.rb
mumuki-domain-6.4.1 app/models/concerns/with_expectations.rb
mumuki-domain-6.4.0 app/models/concerns/with_expectations.rb
mumuki-domain-6.2.2 app/models/concerns/with_expectations.rb
mumuki-domain-6.2.1 app/models/concerns/with_expectations.rb
mumuki-domain-6.3.0 app/models/concerns/with_expectations.rb
mumuki-domain-6.2.0 app/models/concerns/with_expectations.rb
mumuki-domain-6.1.5 app/models/concerns/with_expectations.rb
mumuki-domain-6.0.4 app/models/concerns/with_expectations.rb