Sha256: d8ede519e6d6e3fc2e6cf5c5ab038ece36157995a82a88f618c15eec9cdfcbb3

Contents?: true

Size: 710 Bytes

Versions: 5

Compression:

Stored size: 710 Bytes

Contents

# frozen_string_literal: true

module FaithTeams
  module API
    module V2
      # Wraps entities returned from the faithteams api.
      module Entity
        # Common entity functionality
        class Base
          # New instance of the class.
          def initialize(attributes:)
            @attributes = attributes
          end

          # @return [Hash]
          def to_h
            attributes
          end

          # @return [Boolean]
          def saved?
            !!read_attribute(:id)
          end

          private

          attr_reader :attributes

          def read_attribute(attribute)
            attributes[attribute.to_s]
          end
        end
      end
    end
  end
end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
faithteams-api-4.2.0 lib/faithteams/api/v2/entity/base.rb
faithteams-api-4.1.1 lib/faithteams/api/v2/entity/base.rb
faithteams-api-4.0.1 lib/faithteams/api/v2/entity/base.rb
faithteams-api-2.0.2 lib/faithteams/api/v2/entity/base.rb
faithteams-api-2.0.1 lib/faithteams/api/v2/entity/base.rb