lib/volt/models/model.rb
# When reading an attribute, we need to handle reading on:
# 1) a nil model, which returns a wrapped error
# 2) reading directly from attributes
# 3) trying to read a key that doesn't exist.
When reading an attribute, we need to handle reading on:
1) a nil model, which returns a wrapped error
2) reading directly from attributes
3) trying to read a key that doesn't exist.
When reading an attribute we need to handle reading on : 1 ) a nil model which returns a wrapped error 2 ) reading directly from attributes 3 ) trying to read a key that doesn ' t exist .
def read_attribute(attr_name)
      attr_name = attr_name.to_sym
      if @attributes && @attributes.key?(attr_name)
        @deps.depend(attr_name)
        return @attributes[attr_name]
      else
        new_model              = read_new_model(attr_name)
        @attributes            ||= {}
        @attributes[attr_name] = new_model
        if Volt.in_browser?
          `setImmediate(function() {`
            @size_dep.changed!
          `});`
        else
          @size_dep.changed!
        end
        @deps.depend(attr_name)
        return new_model
      end
    end
def read_attribute ( attr_name ) attr_name = attr_name . to_sym if @attributes && @attributes . key? ( attr_name ) @deps . depend ( attr_name ) return @attributes [ attr_name ] else new_model = read_new_model ( attr_name ) @attributes ||= { } @attributes [ attr_name ] = new_model if Volt . in_browser? ` setImmediate(function() { ` @size_dep . changed! ` }); ` else @size_dep . changed! end @deps . depend ( attr_name ) return new_model end end
When reading an attribute, we need to handle reading on:
1) a nil model, which returns a wrapped error
2) reading directly from attributes
3) trying to read a key that doesn't exist.
When reading an attribute we need to handle reading on : 1 ) a nil model which returns a wrapped error 2 ) reading directly from attributes 3 ) trying to read a key that doesn ' t exist .
# Reading an attribute, we may get back a nil model. # Track dependency # @deps.depend(attr_name) # See if the value is in attributes # Track dependency # Trigger size change # TODO: We can probably improve Computations to just make this work # without the delay # Depend on attribute
attr_name