Sha256: ea56cde03de50b3f5dd9a787312bbf71380e9d2d2cac451846c293b0f98fe552

Contents?: true

Size: 636 Bytes

Versions: 3

Compression:

Stored size: 636 Bytes

Contents

module RestfulObjects
  class TypeList
    extend Forwardable
    include LinkGenerator

    def initialize
      @types = Hash.new
    end

    def add(name)
      @types[name] = Type.new(name)
    end

    def get_representation
      response =  {
       'links' => [
          link_to(:self, '/domain-types', :type_list),
          link_to(:up, '/', :homepage),
        ],
        'value' => []
      }

      each { |name, type| response['value'] << link_to(:domain_type, "/domain-types/#{name}", :domain_type) }

      response.to_json
    end

    def_delegators :@types, :[], :each, :include?, :size?, :clear, :empty?
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
restful_objects-0.0.5 lib/restful_objects/type_list.rb
restful_objects-0.0.4 lib/restful_objects/type_list.rb
restful_objects-0.0.3 lib/restful_objects/type_list.rb