Skip to content

Commit

Permalink
chore: remove timeliness_validation_for helper method to reduce metho…
Browse files Browse the repository at this point in the history
…d pollution
  • Loading branch information
adzap committed Apr 3, 2023
1 parent fdff26b commit a2baae9
Showing 1 changed file with 4 additions and 10 deletions.
14 changes: 4 additions & 10 deletions lib/validates_timeliness/helper_methods.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,25 +3,19 @@ module Validations

module HelperMethods
def validates_date(*attr_names)
timeliness_validation_for attr_names, :date
validates_with TimelinessValidator, _merge_attributes(attr_names).merge(type: :date)
end

def validates_time(*attr_names)
timeliness_validation_for attr_names, :time
validates_with TimelinessValidator, _merge_attributes(attr_names).merge(type: :time)
end

def validates_datetime(*attr_names)
timeliness_validation_for attr_names, :datetime
validates_with TimelinessValidator, _merge_attributes(attr_names).merge(type: :datetime)
end

def validates_timeliness_of(*attr_names)
timeliness_validation_for attr_names
end

def timeliness_validation_for(attr_names, type=nil)
options = _merge_attributes(attr_names)
options.update(:type => type) if type
validates_with TimelinessValidator, options
validates_with TimelinessValidator, _merge_attributes(attr_names)
end
end

Expand Down

0 comments on commit a2baae9

Please sign in to comment.