lib/remarkable/dsl/matches.rb in remarkable-3.0.0 vs lib/remarkable/dsl/matches.rb in remarkable-3.0.1

- old
+ new

@@ -1,11 +1,11 @@ module Remarkable module DSL module Matches # For each instance under the collection declared in <tt>arguments</tt>, - # this method will call each method declared in <tt>assertions</tt>. + # this method will call each method declared in <tt>collection_assertions</tt>. # # As an example, let's assume you have the following matcher: # # arguments :collection => :attributes # assertions :allow_nil?, :allow_blank? @@ -47,19 +47,13 @@ # def default_options {} end - # Overwrites default_i18n_options to provide collection interpolation, - # arguments and optionals to interpolation options. + # Overwrites default_i18n_options to provide arguments and optionals + # to interpolation options. # - # Their are appended in the reverse order above. So if you have an optional - # with the same name as an argument, the argument overwrites the optional. - # - # All values are provided calling inspect, so what you will have in your - # I18n available for interpolation is @options[:allow_nil].inspect. - # # If you still need to provide more other interpolation options, you can # do that in two ways: # # 1. Overwrite interpolation_options: # @@ -74,11 +68,11 @@ # return false, :real_value => real_value # end # # In both cases, :real_value will be available as interpolation option. # - def default_i18n_options + def default_i18n_options #:nodoc: i18n_options = {} @options.each do |key, value| i18n_options[key] = value.inspect end if @options @@ -93,17 +87,15 @@ # Add default options (highest priority). They should not be overwritten. i18n_options.update(super) end - # Methods that return collection_name and object_name as a Hash for - # interpolation. + # Method responsible to add collection as interpolation. # - def collection_interpolation + def collection_interpolation #:nodoc: options = {} - # Add collection to options if collection_name = self.class.matcher_arguments[:collection] collection_name = collection_name.to_sym collection = instance_variable_get("@#{collection_name}") options[collection_name] = array_to_sentence(collection) if collection @@ -113,18 +105,18 @@ end options end - # Helper that send the methods given and create a expectation message if - # any returns false. + # Send the assertion methods given and create a expectation message + # if any of those methods returns false. # # Since most assertion methods ends with an question mark and it's not # readable in yml files, we remove question and exclation marks at the # end of the method name before translating it. So if you have a method # called is_valid? on I18n yml file we will check for a key :is_valid. # - def send_methods_and_generate_message(methods) + def send_methods_and_generate_message(methods) #:nodoc: methods.each do |method| bool, hash = send(method) unless bool @expectation ||= Remarkable.t "expectations.#{method.to_s.gsub(/(\?|\!)$/, '')}",