lib/kanzen.rb in kanzen-0.1.0 vs lib/kanzen.rb in kanzen-0.2.0
- old
+ new
@@ -1,39 +1,47 @@
require 'active_record' unless defined? ActiveRecord
require_relative 'kanzen/inspection'
require_relative 'kanzen/version'
module Kanzen
+ # These are fields that, for the most part, won't be taken
+ # into consideration when calculating the percentage
+ # completed for a given model.
+ #
+ # PS: They are ignored when a custom ignore_list is
+ # passed.
+ DEFAULT_IGNORE_LIST = [:id, :created_at, :updated_at]
+
# Returns true if the model and its associations are
# all filled.
#
# A proc containing a comparison can also be passed
# in order to define if a given attribute is valid or
# not.
- def completed?(proc: nil, ignore_list: nil)
+ def completed?(proc: nil, ignore_list: DEFAULT_IGNORE_LIST)
if proc
return custom_kanzen_calculation(proc, ignore_list)
.completed?
end
kanzen_calculation(ignore_list).completed?
end
# Returns a percentage value for the amount of
# missing attributes.
- def percentage_missing(proc: nil, ignore_list: nil)
+ def percentage_missing(proc: nil, ignore_list: DEFAULT_IGNORE_LIST)
if proc
return custom_kanzen_calculation(proc, ignore_list)
.percentage_missing
end
kanzen_calculation(ignore_list).percentage_missing
end
# Returns a percentage value for the amount of
# present attributes.
- def percentage_present(proc: nil, ignore_list: nil)
+ def percentage_present(proc: nil, ignore_list: DEFAULT_IGNORE_LIST)
if proc
return custom_kanzen_calculation(proc, ignore_list)
.percentage_present
end
@@ -43,11 +51,11 @@
# Returns a hash containing a list of present
# attributes. They are organized in the following
# the order:
#
# your_hash[:model_class] = attribute_name
- def present_attributes(proc: nil, ignore_list: nil)
+ def present_attributes(proc: nil, ignore_list: DEFAULT_IGNORE_LIST)
if proc
return custom_kanzen_calculation(proc, ignore_list)
.present_attributes
end
@@ -57,10 +65,10 @@
# Returns hash containing a list of missing
# attributes. They are organized in the following
# the order:
#
# your_hash[:model_class] = attribute_name
- def missing_attributes(proc: nil, ignore_list: nil)
+ def missing_attributes(proc: nil, ignore_list: DEFAULT_IGNORE_LIST)
if proc
return custom_kanzen_calculation(proc, ignore_list)
.missing_attributes
end