How to forward arguments to parent class?
I'm using the dry-initializer gem (trying to switch to literal) and have things setup this way:
class ParentClass
option :collapsable, default: proc { false }
option :collapsed, default: proc { false }
option :icon, optional: true
end
class ChildClass < ParentClass
option :label
end
With dry-initializer, any extra options passed to the child class are automatically forwarded to the parent class. So, ChildClass.new(label: '..', collapsable: '...', ...) is similar to calling super within the initialize method of the ChildClass. Is there a similar way to do this with literal?
I read the README and there's no mention of anything like this. Does this mean, I can't used literal in this situation?
We use literal this way across our codebase and don't have any issues. It's a bit confusing with positional arguments but otherwise works great.
How this works at the moment is instead of passing arguments to the super initialzer, the sub initializer just inherits all the properties defined on the super class.