class Shoulda::Matchers::ActiveRecord::AssociationMatchers::DependentMatcher
@private
Attributes
Public Class Methods
Source
# File lib/shoulda/matchers/active_record/association_matchers/dependent_matcher.rb, line 9 def initialize(dependent, name) @dependent = dependent @name = name @missing_option = '' end
Public Instance Methods
Source
# File lib/shoulda/matchers/active_record/association_matchers/dependent_matcher.rb, line 15 def description "dependent => #{dependent}" end
Source
# File lib/shoulda/matchers/active_record/association_matchers/dependent_matcher.rb, line 19 def matches?(subject) self.subject = ModelReflector.new(subject, name) if option_matches? true else self.missing_option = generate_missing_option false end end
Private Instance Methods
Source
# File lib/shoulda/matchers/active_record/association_matchers/dependent_matcher.rb, line 51 def generate_missing_option [ "#{name} should have", (dependent == true ? 'a' : dependent), 'dependency', ].join(' ') end
Source
# File lib/shoulda/matchers/active_record/association_matchers/dependent_matcher.rb, line 40 def option_matches? option_verifier.correct_for?(option_type, :dependent, dependent) end
Source
# File lib/shoulda/matchers/active_record/association_matchers/dependent_matcher.rb, line 44 def option_type case dependent when true, false then :boolean else :string end end
Source
# File lib/shoulda/matchers/active_record/association_matchers/dependent_matcher.rb, line 36 def option_verifier @_option_verifier ||= OptionVerifier.new(subject) end