aws / aws-sdk-ruby-record

Official repository for the aws-record gem, an abstraction for Amazon DynamoDB.
Apache License 2.0
318 stars 41 forks source link

Default value lambda improvements #72

Closed natesalisbury closed 4 years ago

natesalisbury commented 7 years ago

Improvements to using a lambda as a default value:

coveralls commented 7 years ago

Coverage Status

Changes Unknown when pulling 08bd9ff6bfde5a80a425156940b892b97e98a34d on natesalisbury:default_value_lambdas into on aws:master.

coveralls commented 7 years ago

Coverage Status

Changes Unknown when pulling 08bd9ff6bfde5a80a425156940b892b97e98a34d on natesalisbury:default_value_lambdas into on aws:master.

coveralls commented 7 years ago

Coverage Status

Changes Unknown when pulling 08bd9ff6bfde5a80a425156940b892b97e98a34d on natesalisbury:default_value_lambdas into on aws:master.

coveralls commented 7 years ago

Coverage Status

Changes Unknown when pulling b5e0e8fe495cd8cd9f8c555b8a54e2bc0f0f4de6 on natesalisbury:default_value_lambdas into on aws:master.

natesalisbury commented 7 years ago

@awood45 any feedback for these changes?

awood45 commented 7 years ago

Sorry, haven't had a chance to review yet. It's on my work backlog.

natesalisbury commented 7 years ago

No worries, thanks!

metaskills commented 5 years ago

Was interested in using default values today and was surprised that this was not the behavior. In fact, would this PR solve a bug? I am not sure why storing a proc as a string would be the expected results?

metaskills commented 5 years ago

Like, is this the expected way to use a default value for a hash key?

class MyModel
  include Aws::Record
  string_attr       :prefix, hash_key: true
  string_attr       :description

  def initialize(*args)
    super
    self.prefix ||= new_prefix
  end

  # ...
end
alextwoods commented 4 years ago

Apologies it has taken us so long to get around to reviewing this change. Overall it looks good, however, in ItemData#populate_default_values, the default_value lambda will end up getting called twice.

I'm happy to fix that later today.