Sha256: 332d32694e82eeea81923386ce2bc7e3b5940cd8ea128a818455f6775b99aad7

Contents?: true

Size: 668 Bytes

Versions: 8

Compression:

Stored size: 668 Bytes

Contents

require 'virtus'

module SearchKit
  module Models
    class Subscriber
      include Virtus.model

      attribute :email, String
      attribute :id,    String
      attribute :keys,  SearchKit::Models::Keys[SearchKit::Models::Key]
      attribute :uri,   String

      def initialize(subscriber_data = {})
        attributes = subscriber_data.fetch(:attributes, {})
        keys       = subscriber_data.fetch(:relationships, {}).fetch(:keys, [])
        uri        = subscriber_data.fetch(:links, {}).fetch(:self, '')

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

      def creator_tokens
        keys.creator.tokens
      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/subscriber.rb
search-kit-0.0.9 lib/search_kit/models/subscriber.rb
search-kit-0.0.8 lib/search_kit/models/subscriber.rb
search-kit-0.0.7 lib/search_kit/models/subscriber.rb
search-kit-0.0.6 lib/search_kit/models/subscriber.rb
search-kit-0.0.5 lib/search_kit/models/subscriber.rb
search-kit-0.0.4 lib/search_kit/models/subscriber.rb
search-kit-0.0.3 lib/search_kit/models/subscriber.rb