lib/asciidoctor/abstract_node.rb in asciidoctor-1.5.0 vs lib/asciidoctor/abstract_node.rb in asciidoctor-1.5.1
- old
+ new
@@ -25,23 +25,21 @@
attr_reader :attributes
def initialize parent, context, opts = {}
# document is a special case, should refer to itself
if context == :document
- @parent = nil
@document = parent
else
- if (@parent = parent)
+ if parent
+ @parent = parent
@document = parent.document
- else
- @document = nil
end
end
@context = context
@node_name = context.to_s
# QUESTION are we correct in duplicating the attributes (seems to be just as fast)
- @attributes = opts.key?(:attributes) ? (opts[:attributes] || {}).dup : {}
+ @attributes = (opts.key? :attributes) ? opts[:attributes].dup : {}
@passthroughs = {}
end
# Public: Associate this Block with a new parent Block
#
@@ -187,13 +185,13 @@
@document.converter
end
# Public: A convenience method that checks if the role attribute is specified
def role?(expect = nil)
- if expect.nil?
- @attributes.has_key?('role') || @document.attributes.has_key?('role')
- else
+ if expect
expect == (@attributes['role'] || @document.attributes['role'])
+ else
+ @attributes.has_key?('role') || @document.attributes.has_key?('role')
end
end
# Public: A convenience method that returns the value of the role attribute
def role