Skip to content

Bug: nil default value of Array attribute ignored #369

Description

@csokol

I think I found a bug in virtus.

It looks like the default parameter is being ignored for Array attributes. Here's how to reproduce:

require 'virtus'
class Foo
  include Virtus.model

  attribute :array, Array, default: nil
  attribute :hash, Hash, default: nil
  attribute :string, String, default: nil
end
require './foo.rb'
require 'test/unit/assertions'
include Test::Unit::Assertions


f = Foo.new({})
assert(f.string.nil?, 'string should be nil')
assert(f.hash.nil?, 'hash should be nil')

p f.array
assert(f.array.nil?, 'array should be nil')

Am I missing something or is this a real bug?

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions