Sha256: 07fa7ff501fa02478e2f5e7526722d24d0d0ffa03289273e84e94eb182ca3de0

Contents?: true

Size: 697 Bytes

Versions: 52

Compression:

Stored size: 697 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 own_custom_expectations
    self[:custom_expectations]
  end

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

Version data entries

52 entries across 52 versions & 2 rubygems

Version Path
mumuki-domain-8.1.2 app/models/concerns/with_expectations.rb
mumuki-domain-8.1.1 app/models/concerns/with_expectations.rb
mumuki-domain-8.1.0 app/models/concerns/with_expectations.rb
mumuki-domain-8.0.0 app/models/concerns/with_expectations.rb
mumuki-domain-7.12.2 app/models/concerns/with_expectations.rb
mumuki-domain-7.12.1 app/models/concerns/with_expectations.rb
mumuki-domain-7.12.0 app/models/concerns/with_expectations.rb
mumuki-domain-7.11.1 app/models/concerns/with_expectations.rb
mumuki-laboratory-7.11.1 vendor/bundle/ruby/2.6.0/bundler/gems/mumuki-domain-c92f2a7212e2/app/models/concerns/with_expectations.rb
mumuki-laboratory-7.11.0 vendor/bundle/ruby/2.6.0/bundler/gems/mumuki-domain-2e15c3330133/app/models/concerns/with_expectations.rb
mumuki-domain-7.11.0 app/models/concerns/with_expectations.rb
mumuki-domain-7.10.1 app/models/concerns/with_expectations.rb
mumuki-domain-7.10.0 app/models/concerns/with_expectations.rb
mumuki-laboratory-7.9.2 vendor/bundle/ruby/2.6.0/bundler/gems/mumuki-domain-7082a83493eb/app/models/concerns/with_expectations.rb
mumuki-domain-7.9.2 app/models/concerns/with_expectations.rb
mumuki-laboratory-7.9.1 vendor/bundle/ruby/2.6.0/bundler/gems/mumuki-domain-b162dc91aa77/app/models/concerns/with_expectations.rb
mumuki-domain-7.9.1 app/models/concerns/with_expectations.rb
mumuki-laboratory-7.9.0 vendor/bundle/ruby/2.6.0/bundler/gems/mumuki-domain-520f859ca8af/app/models/concerns/with_expectations.rb
mumuki-domain-7.9.0 app/models/concerns/with_expectations.rb
mumuki-domain-7.7.3 app/models/concerns/with_expectations.rb