Closed hallgren closed 8 years ago
For a minute there I thought you had written a pull request :) I think it's a good suggestion. If anyone feels like implementing it I'm happy to provide some mentoring.
I talked to @bjoska about this and he wasn´t sure this was the intention when the options are set to nil in attribute.rb
.
module Yaks
class Mapper
class Attribute
include Attribs.new(:name, :block)
include Util
def self.create(name, _options = nil, &block) <--
new(name: name, block: block)
end
def add_to_resource(resource, mapper, _context)
if block
attribute = Resolve(block, mapper)
else
attribute = mapper.load_attribute(name)
end
resource.merge_attributes(name => attribute)
end
end
end
end
I´ll try to create a PR for this now when you say its ok :)
The reason _options
is nil
there and not {}
is that it's an unused parameter (hence the underscore name), and using {}
will cause mutant to complain.
The reason _options is nil there and not {} is that it's an unused parameter (hence the underscore name)
That is what I said. :smile:
and using {} will cause mutant to complain.
I think Morgan got around this. :smile:
I looked how link.rb
worked and was lucky.
Add option to the attribute method to make the attribute optional.