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
- #progress_complete_count ⇒ Object
- #progress_count ⇒ Object
- #progress_percent ⇒ Object
- #soft_errors ⇒ Object
- #soft_valid? ⇒ Boolean
Instance Method Details
#progress_complete_count ⇒ Object
15 16 17 |
# File 'lib/soft_validate.rb', line 15 def progress_complete_count self.soft_attributes.length end |
#progress_count ⇒ Object
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_percent ⇒ Object
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_errors ⇒ Object
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
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 |