class Doctrine::Definition
Public Class Methods
subject(value = value_omitted = true, &block)
click to toggle source
# File lib/doctrine/definition.rb, line 10 def subject(value = value_omitted = true, &block) if block @subject = block @subject_type = :block elsif !value_omitted @subject = value @subject_type = :value end end
tenet(description, &block)
click to toggle source
# File lib/doctrine/definition.rb, line 20 def tenet(description, &block) tenets << Tenet.new(description: description, &block) end
Public Instance Methods
assert() { |resolve(subject, subject_type)| ... }
click to toggle source
- public
# File lib/doctrine/definition.rb, line 42 def assert subject, subject_type = find_subject_and_subject_type if subject_type unless yield(resolve(subject, subject_type)) raise AssertionFailed end else raise UndefinedSubject end end
capture() { || ... }
click to toggle source
- public
# File lib/doctrine/definition.rb, line 56 def capture yield rescue => error @subject_type = :error @subject = error end
subject(value = value_omitted = true, &block)
click to toggle source
- public
# File lib/doctrine/definition.rb, line 30 def subject(value = value_omitted = true, &block) if block @subject = block @subject_type = :block elsif !value_omitted @subject = value @subject_type = :value end end
Private Instance Methods
find_subject_and_subject_type()
click to toggle source
# File lib/doctrine/definition.rb, line 63 def find_subject_and_subject_type if @subject_type [@subject, @subject_type] elsif (subject_type = self.class.instance_variable_get(:@subject_type)) [self.class.instance_variable_get(:@subject), subject_type] end end
resolve(subject, subject_type)
click to toggle source
# File lib/doctrine/definition.rb, line 71 def resolve(subject, subject_type) case subject_type when :block subject.call when :error, :value subject end end