Module: WithExpectations

Extended by:
ActiveSupport::Concern
Included in:
Guide, Problem
Defined in:
app/models/concerns/with_expectations.rb

Instance Method Summary collapse

Instance Method Details

#ensure_expectations_formatObject



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_yamlObject



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_expectationsObject



25
26
27
# File 'app/models/concerns/with_expectations.rb', line 25

def own_custom_expectations
  self[:custom_expectations]
end

#own_expectationsObject



21
22
23
# File 'app/models/concerns/with_expectations.rb', line 21

def own_expectations
  self[:expectations]
end