lib/volt/models/model.rb
def read_attribute(method_name)
    # Reading an attribute, we may get back a nil model.
    method_name = method_name.to_sym

    if method_name[0] != '_' && attributes == nil
      # The method we are calling is on a nil model, return a wrapped
      # exception.
      return return_undefined_method(method_name)
    else
      # See if the value is in attributes
      value = (attributes && attributes[method_name])

      # Also check @cache
      value ||= (@cache && @cache[method_name])

      if value
        # key was in attributes or cache
        return value
      else
        # Cache the value, will be removed when expanded or something
        # is assigned over it.
        # TODO: implement a timed out cache flusing
        new_model = read_new_model(method_name)
        @cache[method_name] = new_model

        return new_model
      end
    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.
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(method_name)
    method_name = method_name.to_sym
    if method_name[0] != '_' && attributes == nil
      return return_undefined_method(method_name)
    else
      value = (attributes && attributes[method_name])
      value ||= (@cache && @cache[method_name])
      if value
        return value
      else
        new_model = read_new_model(method_name)
        @cache[method_name] = new_model
        return new_model
      end
    end
  end
def read_attribute ( method_name ) method_name = method_name . to_sym if method_name [ 0 ] != '_' && attributes == nil return return_undefined_method ( method_name ) else value = ( attributes && attributes [ method_name ] ) value ||= ( @cache && @cache [ method_name ] ) if value return value else new_model = read_new_model ( method_name ) @cache [ method_name ] = new_model return new_model end 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. # The method we are calling is on a nil model, return a wrapped # exception. # See if the value is in attributes # Also check @cache # key was in attributes or cache # Cache the value, will be removed when expanded or something # is assigned over it. # TODO: implement a timed out cache flusing
method_name