Sha256: a45d5f39f70bbf29772b2068d82c92718764a3d29bb365e3f683bfff58a19127

Contents?: true

Size: 638 Bytes

Versions: 2

Compression:

Stored size: 638 Bytes

Contents

# frozen_string_literal: true

module Windcharger
  module Attributes
    def attributes
      (@__attributes || []).dup.freeze
    end

    private

    def __windcharger_add_attribute name
      (@__attributes ||= []) << name.to_sym
    end

    def attribute *attributes
      if attributes.any?
        attributes.each { |attribute| __windcharger_add_attribute attribute }
      else
        @__windcharger_next_is_attribute = true
      end
    end

    def method_added name
      return unless @__windcharger_next_is_attribute
      __windcharger_add_attribute name
      @__windcharger_next_is_attribute = false
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
windcharger-0.5.0 lib/windcharger/attributes.rb
windcharger-0.4.0 lib/windcharger/attributes.rb