def define_writer!(k, definition)
      define_method("#{k}=") do |value|
        # Recursively convert hash and array of hash to schematized objects
        value = ensure_schema value, definition[:schema]

        # Initial value
        instance_variable_set "@#{k}", value

        # Dirty tracking
        self.changed_attributes ||= Set.new
        self.changed_attributes << k
      end
    end
def define_writer!(k, definition)
      define_method("#{k}=") do |value|
        # Recursively convert hash and array of hash to schematized objects
        value = ensure_schema value, definition[:schema]

        # Initial value
        instance_variable_set "@#{k}", value

        # Dirty tracking
        self.changed_attributes ||= Set.new
        self.changed_attributes << k
      end
    end
Helper for dynamically defining writer method
 @param [Symbol] k - name of attribute
 @param [Hash] definition - See docstring for schema above