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



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

def ensure_expectations_format
  errors.add :raw_expectations,
             :invalid_format unless raw_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

#raw_expectationsObject



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

def raw_expectations
  self[:expectations]
end