Module: SoftValidate

Extended by:
ActiveSupport::Concern
Defined in:
lib/soft_validate.rb,
lib/soft_validate/version.rb

Defined Under Namespace

Modules: ClassMethods

Constant Summary collapse

VERSION =
"0.0.3"

Instance Method Summary collapse

Instance Method Details

#progress_complete_countObject



15
16
17
# File 'lib/soft_validate.rb', line 15

def progress_complete_count
  self.soft_attributes.length
end

#progress_countObject



27
28
29
# File 'lib/soft_validate.rb', line 27

def progress_count
  self.soft_attributes.count { |a| !self.attributes[a.to_s].blank? }
end

#progress_percentObject



31
32
33
# File 'lib/soft_validate.rb', line 31

def progress_percent
  self.progress_count.to_f / self.progress_complete_count.to_f
end

#soft_errorsObject



23
24
25
# File 'lib/soft_validate.rb', line 23

def soft_errors
  Hash[ self.soft_attributes.map { |a| [a, "shouldn't be blank"] if self.attributes[a.to_s].blank? } ]
end

#soft_valid?Boolean

Returns:

  • (Boolean)


19
20
21
# File 'lib/soft_validate.rb', line 19

def soft_valid?
  self.soft_attributes.all? { |a| !self.attributes[a.to_s].blank? }
end