Sha256: ef6e50f7ba43ca4cf98bd4ab8bf16c517b750dbd86256f4a86932930396e114b

Contents?: true

Size: 555 Bytes

Versions: 8

Compression:

Stored size: 555 Bytes

Contents

require 'virtus'

module SearchKit
  module Models
    class Key
      include Virtus.model

      attribute :id,        String
      attribute :name,      String
      attribute :privilege, String
      attribute :token,     String
      attribute :uri,       String

      def initialize(key_data = {})
        attributes = key_data.fetch(:attributes, {})
        uri        = key_data.fetch(:links, {}).fetch(:self, '')

        super(attributes.merge(uri: uri))
      end

      def creator?
        privilege == 'creator'
      end
    end
  end
end

Version data entries

8 entries across 8 versions & 1 rubygems

Version Path
search-kit-0.0.10 lib/search_kit/models/key.rb
search-kit-0.0.9 lib/search_kit/models/key.rb
search-kit-0.0.8 lib/search_kit/models/key.rb
search-kit-0.0.7 lib/search_kit/models/key.rb
search-kit-0.0.6 lib/search_kit/models/key.rb
search-kit-0.0.5 lib/search_kit/models/key.rb
search-kit-0.0.4 lib/search_kit/models/key.rb
search-kit-0.0.3 lib/search_kit/models/key.rb