Sha256: 48b71f3996aec7d4f330eb5f1500f5654cae43f96f963c4a5e4a369f3ec712e2

Contents?: true

Size: 1.11 KB

Versions: 11

Compression:

Stored size: 1.11 KB

Contents

require 'roar/representer/json'
require 'billit_representers/models/bill_basic'
require 'billit_representers/representers/bill_basic_representer'

module Billit
  module BillPageRepresenter

    include Roar::Representer::JSON
    include Roar::Representer::Feature::Hypermedia

    module Initializer
      def initialize
        extend Billit::BillPageRepresenter
        extend Roar::Representer::Feature::Client
        super
      end
    end

    def self.included(klass)
      klass.send :prepend, Initializer
      klass.send :include, Roar::Representer::Feature::HttpVerbs
    end

    collection :bills, :extend => Billit::BillBasicRepresenter, :class => Billit::BillBasic

    property :total_entries
    property :current_page
    property :total_pages
   
    link :self do |params|
      url_for(params.merge(:page => current_page))
    end
   
    link :next do |params|
      url_for(params.merge(:page => next_page)) \
        if next_page
    end
   
    link :previous do |params|
      url_for(params.merge(:page => previous_page)) \
        if previous_page
    end
   
    def bills
      self
    end
  end
end

Version data entries

11 entries across 11 versions & 1 rubygems

Version Path
billit_representers-0.9.10 lib/billit_representers/representers/bill_page_representer.rb
billit_representers-0.9.9 lib/billit_representers/representers/bill_page_representer.rb
billit_representers-0.9.8 lib/billit_representers/representers/bill_page_representer.rb
billit_representers-0.9.7 lib/billit_representers/representers/bill_page_representer.rb
billit_representers-0.9.6 lib/billit_representers/representers/bill_page_representer.rb
billit_representers-0.9.5 lib/billit_representers/representers/bill_page_representer.rb
billit_representers-0.9.4 lib/billit_representers/representers/bill_page_representer.rb
billit_representers-0.9.3 lib/billit_representers/representers/bill_page_representer.rb
billit_representers-0.9.2 lib/billit_representers/representers/bill_page_representer.rb
billit_representers-0.9.1 lib/billit_representers/representers/bill_page_representer.rb
billit_representers-0.9.0 lib/billit_representers/representers/bill_page_representer.rb