lib/chozo/varia_model.rb in chozo-0.2.0 vs lib/chozo/varia_model.rb in chozo-0.2.1

- old
+ new

@@ -166,9 +166,22 @@ # @return [HashWithIndifferentAccess] def errors @errors ||= HashWithIndifferentAccess.new end + # @param [#to_s] key + # + # @return [Object] + def get_attribute(key) + self.attributes.dig(key.to_s) + end + + # @param [#to_s] key + # @param [Object] value + def set_attribute(key, value) + self.attributes.deep_merge!(attributes.class.from_dotted_path(key.to_s, value)) + end + protected # @param [String] attribute # @param [String] message def add_error(attribute, message)