Sha256: e6e397ce519ac5469b08301ebe7f8219abb22e2705fc3d6284438e9da65966da

Contents?: true

Size: 1015 Bytes

Versions: 2

Compression:

Stored size: 1015 Bytes

Contents

module MediaTypes
  class People < Praxis::MediaTypeCollection
    identifier 'application/json'

    view :default do
      @contents.merge!(@schema.attributes)
    end
  end

  class Person < Praxis::MediaType
    attributes do
      attribute :id, Integer
      attribute :name, String, example: /[:name:]/
      attribute :href, String, example: proc { |person| "/people/#{person.id}" }
    end

    view :default do
      attribute :id
      attribute :name
    end

    view :link do
      attribute :id
      attribute :name
      attribute :href
    end
  end

  class Address < Praxis::MediaType
    identifier 'application/json'

    description 'Address MediaType'

    attributes do
      attribute :id, Integer
      attribute :name, String

      attribute :owner, Person

      links do
        link :owner
        link :super, Person, using: :manager
      end

    end

    view :default do
      attribute :id
      attribute :name
      attribute :owner

      attribute :links
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
traxis-0.0.2 spec/support/media_types.rb
traxis-0.0.1 spec/support/media_types.rb