Sha256: de9389ae8590df0b4c9f6e6d05dcc0b47d8a9b8be93e23eec8a4735f3563fbf2

Contents?: true

Size: 1.19 KB

Versions: 4

Compression:

Stored size: 1.19 KB

Contents

require 'roar/representer'
require 'roar/representer/feature/http_verbs'
require 'roar/representer/feature/client'
require 'roar/representer/json'
require 'roar/representer/json/hal'
# require 'roar/rails/hal'
require 'billit_representers/representers/vote_event_representer'
require 'billit_representers/representers/count_representer'
require 'billit_representers/models/vote_event'
require 'billit_representers/models/count'

module Billit
  module MotionRepresenter
    include Roar::Representer::JSON::HAL

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

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

    property :organization
    property :context
    property :creator
    property :text
    property :date
    property :requirement
    property :result
    property :session

    collection :vote_events, extend: Billit::VoteEventRepresenter, class: lambda { |x, *| Object.const_defined?("VoteEvent") ? VoteEvent : BillitVoteEvent }

    link :self do
      motion_url(self.id)
    end
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
billit_representers-0.9.10 lib/billit_representers/representers/motion_representer.rb
billit_representers-0.9.9 lib/billit_representers/representers/motion_representer.rb
billit_representers-0.9.8 lib/billit_representers/representers/motion_representer.rb
billit_representers-0.9.7 lib/billit_representers/representers/motion_representer.rb