Sha256: 7eec962d15f81867b511fa6e7fb00e1c71c6c928bda3030fcba5fb9a801962d3

Contents?: true

Size: 1.03 KB

Versions: 18

Compression:

Stored size: 1.03 KB

Contents

module CSL
  module InheritableNameOptions
    def inheritable_name_options
      options = attributes_for(*Schema.attr(:name))

      if attribute?(:'name-delimiter')
        options[:delimiter] = attributes[:'name-delimiter']
      end

      if attribute?(:'name-form')
        options[:form] = attributes[:'name-form']
      end

      options
    end

    def inheritable_names_options
      return {} unless attribute? :'names-delimiter'
      { :delimiter => attributes[:'names-delimiter'] }
    end
  end

  module InheritsNameOptions
    def inherits(name)
      inheritable_options = "inheritable_#{name}".to_sym

      define_method("inherited_#{name}") do |node, style|
        options = {}

        if node.respond_to?(inheritable_options)
          options = node.send(inheritable_options).merge(options)
        end

        style ||= root

        if !style.equal?(self) && style.respond_to?(inheritable_options)
          options = style.send(inheritable_options).merge(options)
        end

        options
      end
    end
  end
end

Version data entries

18 entries across 18 versions & 1 rubygems

Version Path
csl-2.0.0 lib/csl/name_options.rb
csl-1.6.0 lib/csl/name_options.rb
csl-1.5.2 lib/csl/name_options.rb
csl-1.5.1 lib/csl/name_options.rb
csl-1.5.0 lib/csl/name_options.rb
csl-1.4.5 lib/csl/name_options.rb
csl-1.4.4 lib/csl/name_options.rb
csl-1.4.3 lib/csl/name_options.rb
csl-1.4.2 lib/csl/name_options.rb
csl-1.4.1 lib/csl/name_options.rb
csl-1.4.0 lib/csl/name_options.rb
csl-1.3.2 lib/csl/name_options.rb
csl-1.3.1 lib/csl/name_options.rb
csl-1.3.0 lib/csl/name_options.rb
csl-1.2.3 lib/csl/name_options.rb
csl-1.2.2 lib/csl/name_options.rb
csl-1.2.1 lib/csl/name_options.rb
csl-1.2.0 lib/csl/name_options.rb