Module: Ecoportal::API::Common::Content::DoubleModel::Attributable::Enforce::ClassMethods
- Defined in:
- lib/ecoportal/api/common/content/double_model/attributable/enforce.rb
Instance Method Summary collapse
-
#enforce!(doc) ⇒ Object
Ensures
dochas themodel_forced_keys. -
#passforced(method, default:, read_only: false) ⇒ Object
These are methods that should always be present in patch update.
Instance Method Details
#enforce!(doc) ⇒ Object
Ensures doc has the model_forced_keys. If it doesn't, it adds those
missing with the defined default values
38 39 40 41 42 43 44 45 46 47 |
# File 'lib/ecoportal/api/common/content/double_model/attributable/enforce.rb', line 38 def enforce!(doc) return unless doc.is_a?(Hash) return if model_forced_keys.empty? model_forced_keys.each do |key, default| doc[key] = default unless doc.key?(key) end doc end |
#passforced(method, default:, read_only: false) ⇒ Object
Note:
DoubleModelcan be used with objects that do not usepatch_ver- This ensures that they will get the correct patch update model.
These are methods that should always be present in patch update
31 32 33 34 |
# File 'lib/ecoportal/api/common/content/double_model/attributable/enforce.rb', line 31 def passforced(method, default:, read_only: false) model_forced_keys[method.to_s.freeze] = default passthrough(method, read_only: read_only) end |