Sha256: f4b8fe70102d1743b7aed5451663bf0ce372b815bd29c25fcef72d93ba3395d4

Contents?: true

Size: 1.31 KB

Versions: 2

Compression:

Stored size: 1.31 KB

Contents

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

  view :default do
    attribute :id
    attribute :name
    attribute :links
  end

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

  class CollectionSummary < Praxis::MediaType
    attributes do
      attribute :href, String
      attribute :size, Integer
    end

    view :link do
      attribute :href
      attribute :size
    end

  end
end


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

  description 'Address MediaType'
  display_name 'The Address'

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

    attribute :owner, Person
    attribute :custodian, Person

    attribute :residents, Praxis::Collection.of(Person)
    attribute :residents_summary, Person::CollectionSummary

    links do
      link :owner
      link :super, Person, using: :manager
      link :caretaker, using: :custodian
      link :residents, using: :residents_summary
    end

  end

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

    attribute :links
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
praxis-0.18.1 spec/support/spec_media_types.rb
praxis-0.18.0 spec/support/spec_media_types.rb