module Micro::Attributes::Features::Accept
Constants
- Context
- KeepProc
Public Instance Methods
accepted_attributes()
click to toggle source
# File lib/micro/attributes/features/accept.rb, line 18 def accepted_attributes @__accepted_attributes ||= defined_attributes - rejected_attributes end
accepted_attributes?()
click to toggle source
# File lib/micro/attributes/features/accept.rb, line 26 def accepted_attributes? !rejected_attributes? end
attributes_errors()
click to toggle source
# File lib/micro/attributes/features/accept.rb, line 6 def attributes_errors @__attributes_errors end
attributes_errors?()
click to toggle source
# File lib/micro/attributes/features/accept.rb, line 10 def attributes_errors? !@__attributes_errors.empty? end
rejected_attributes()
click to toggle source
# File lib/micro/attributes/features/accept.rb, line 14 def rejected_attributes @__rejected_attributes ||= attributes_errors.keys end
rejected_attributes?()
click to toggle source
# File lib/micro/attributes/features/accept.rb, line 22 def rejected_attributes? attributes_errors? end
Private Instance Methods
__attribute_accept_or_reject(key, value, validation_data)
click to toggle source
# File lib/micro/attributes/features/accept.rb, line 48 def __attribute_accept_or_reject(key, value, validation_data) context = Context.with(key, value, validation_data) error_msg = context.rejection_message(Validate.call(context)) @__attributes_errors[key] = error_msg if error_msg end
__attribute_assign(key, init_hash, attribute_data)
click to toggle source
# File lib/micro/attributes/features/accept.rb, line 38 def __attribute_assign(key, init_hash, attribute_data) validation_data = attribute_data[1] value_to_assign = FetchValueToAssign.(init_hash, init_hash[key], attribute_data, KeepProc.(validation_data)) value = __attributes[key] = instance_variable_set("@#{key}", value_to_assign) __attribute_accept_or_reject(key, value, validation_data) if !validation_data.empty? end
__call_before_attributes_assign()
click to toggle source
# File lib/micro/attributes/features/accept.rb, line 32 def __call_before_attributes_assign @__attributes_errors = {} end