Remove duplication with new `has_attribute`

Instead of repeating the pattern

```ruby
def type
  @type ||= @data.fetch 'type', ''
end
```

the code is now more compact and readable:

```ruby
has_attribute :type, default: ''
```
Merge branch 'has-attribute'