Sha256: 22ae1eaef6bf5c7f269702d400ff2ce8f45bca83eb846ffd44547584d3a95f97

Contents?: true

Size: 1.29 KB

Versions: 5

Compression:

Stored size: 1.29 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'

  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

5 entries across 5 versions & 1 rubygems

Version Path
praxis-0.17.1 spec/support/spec_media_types.rb
praxis-0.17.0 spec/support/spec_media_types.rb
praxis-0.16.1 spec/support/spec_media_types.rb
praxis-0.16.0 spec/support/spec_media_types.rb
praxis-0.15.0 spec/support/spec_media_types.rb