lib/volt/models/model.rb
def assign_attribute(method_name, *args, &block)
      self.expand!
      # Assign, without the =
      attribute_name = method_name.to_sym

      value = args[0]

      old_value = @attributes[attribute_name]
      new_value = wrap_value(value, [attribute_name])

      if old_value != new_value
        @attributes[attribute_name] = new_value

        @deps.changed!(attribute_name)

        if old_value == nil || new_value == nil
          @size_dep.changed!
        end

        # TODO: Can we make this so it doesn't need to be handled for non store collections
        # (maybe move it to persistor, though thats weird since buffers don't have a persistor)
        clear_server_errors(attribute_name) if @server_errors

        # Don't save right now if we're in a nosave block
        if !defined?(Thread) || !Thread.current['nosave']
          # Let the persistor know something changed
          @persistor.changed(attribute_name) if @persistor
        end
      end
    end
# Do the assignment to a model and trigger a changed event
Do the assignment to a model and trigger a changed event
Do the assignment to a model and trigger a changed event
def assign_attribute(method_name, *args, &block)
      self.expand!
      attribute_name = method_name.to_sym
      value = args[0]
      old_value = @attributes[attribute_name]
      new_value = wrap_value(value, [attribute_name])
      if old_value != new_value
        @attributes[attribute_name] = new_value
        @deps.changed!(attribute_name)
        if old_value == nil || new_value == nil
          @size_dep.changed!
        end
        clear_server_errors(attribute_name) if @server_errors
        if !defined?(Thread) || !Thread.current['nosave']
          @persistor.changed(attribute_name) if @persistor
        end
      end
    end
def assign_attribute ( method_name , * args , & block ) self . expand! attribute_name = method_name . to_sym value = args [ 0 ] old_value = @attributes [ attribute_name ] new_value = wrap_value ( value , [ attribute_name ] ) if old_value != new_value @attributes [ attribute_name ] = new_value @deps . changed! ( attribute_name ) if old_value == nil || new_value == nil @size_dep . changed! end clear_server_errors ( attribute_name ) if @server_errors if ! defined? ( Thread ) || ! Thread . current [ 'nosave' ] @persistor . changed ( attribute_name ) if @persistor end end end
Do the assignment to a model and trigger a changed event
Do the assignment to a model and trigger a changed event
# Assign, without the = # TODO: Can we make this so it doesn't need to be handled for non store collections # (maybe move it to persistor, though thats weird since buffers don't have a persistor) # Don't save right now if we're in a nosave block # Let the persistor know something changed
method_name
args
block