Skip to content

Inheritance support #9

@alexsotocx

Description

@alexsotocx

Hello I'm facing the issue with inheritance, attributes are not being copied.

Ruby 2.3.1
model_attribute (3.1.1)

require 'model_attribute'
class Person
  extend ModelAttribute
  attribute :name,       :string
  attribute :last_name,       :string

  def initialize(attributes = {})
    set_attributes(attributes)
  end
end


class User < Person

  def initialize(attributes = {})
    super(attributes)
    self.name = "This is an error"
  end
end


User.attributes # nil
User.new({})

# /Users/soto/.rvm/gems/ruby-2.3.1/gems/model_attribute-3.1.1/lib/model_attribute.rb:87:in `read_attribute': undefined method `include?' for nil:NilClass (NoMethodError)
# 	from /Users/soto/.rvm/gems/ruby-2.3.1/gems/model_attribute-3.1.1/lib/model_attribute.rb:66:in `write_attribute'
# 	from /Users/soto/.rvm/gems/ruby-2.3.1/gems/model_attribute-3.1.1/lib/model_attribute.rb:27:in `name='
# 	from script.rb:17:in `initialize'
# 	from script.rb:22:in `new'
# 	from script.rb:22:in `<main>'

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions