Sha256: 5f2ffb7d94eaa37eccc21e1429f601f2f26abeecab47871b9176b4a42a1ea5ec

Contents?: true

Size: 611 Bytes

Versions: 9

Compression:

Stored size: 611 Bytes

Contents

# frozen_string_literal: true

module Panko
  class Attribute
    def self.create(name, alias_name: nil)
      alias_name = alias_name.to_s unless alias_name.nil?
      Attribute.new(name.to_s, alias_name)
    end

    def ==(attr)
      return name.to_sym == attr if attr.is_a? Symbol
      return name == attr.name && alias_name == attr.alias_name if attr.is_a? Panko::Attribute

      super
    end

    def hash
      name.to_sym.hash
    end

    def eql?(attr)
      self.==(attr)
    end

    def inspect
      "<Panko::Attribute name=#{name.inspect} alias_name=#{alias_name.inspect}>"
    end
  end
end

Version data entries

9 entries across 9 versions & 1 rubygems

Version Path
panko_serializer-0.7.7 lib/panko/attribute.rb
panko_serializer-0.7.6 lib/panko/attribute.rb
panko_serializer-0.7.5 lib/panko/attribute.rb
panko_serializer-0.7.4 lib/panko/attribute.rb
panko_serializer-0.7.3 lib/panko/attribute.rb
panko_serializer-0.7.2 lib/panko/attribute.rb
panko_serializer-0.7.1 lib/panko/attribute.rb
panko_serializer-0.7.0 lib/panko/attribute.rb
panko_serializer-0.6.0 lib/panko/attribute.rb