Class: Shoulda::Matchers::ActiveModel::ValidationMatcher::BuildDescription

Inherits:
Object
  • Object
show all
Defined in:
lib/shoulda/matchers/active_model/validation_matcher/build_description.rb

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(matcher, main_description) ⇒ BuildDescription

Returns a new instance of BuildDescription.



11
12
13
14
# File 'lib/shoulda/matchers/active_model/validation_matcher/build_description.rb', line 11

def initialize(matcher, main_description)
  @matcher = matcher
  @main_description = main_description
end

Class Method Details

.call(matcher, main_description) ⇒ Object



7
8
9
# File 'lib/shoulda/matchers/active_model/validation_matcher/build_description.rb', line 7

def self.call(matcher, main_description)
  new(matcher, main_description).call
end

Instance Method Details

#callObject



16
17
18
19
20
21
22
23
# File 'lib/shoulda/matchers/active_model/validation_matcher/build_description.rb', line 16

def call
  if description_clauses_for_qualifiers.any?
    "#{main_description}#{clause_for_allow_blank_or_nil},"\
    " #{description_clauses_for_qualifiers.to_sentence}"
  else
    main_description + clause_for_allow_blank_or_nil
  end
end