Sha256: 5dff48e390624c379f81ac9fc5449315a7b57c9245fd771e009437cd88ae0bc2

Contents?: true

Size: 581 Bytes

Versions: 25

Compression:

Stored size: 581 Bytes

Contents

module Clinical
  class Collection < WillPaginate::Collection
    include HappyMapper
    attr_accessor :count
    class << self
      def create_from_results(page, per_page, body)
        results = SearchResult.parse(body)
        col = create(page, per_page, results.count || 0) do |pager|
          pager.replace(results.trials)
        end
        col.count = results.count
        col
      end
    end
    
    class SearchResult
      include HappyMapper
      tag "search_results"
      attribute "count", Integer

      has_many :trials, Clinical::Trial
    end
  end
end

Version data entries

25 entries across 25 versions & 2 rubygems

Version Path
dpickett-clinical-0.1.0 lib/clinical/collection.rb
dpickett-clinical-0.1.1 lib/clinical/collection.rb
dpickett-clinical-0.1.2 lib/clinical/collection.rb
dpickett-clinical-0.1.3 lib/clinical/collection.rb
dpickett-clinical-0.1.4 lib/clinical/collection.rb
dpickett-clinical-0.1.5 lib/clinical/collection.rb
dpickett-clinical-0.2.0 lib/clinical/collection.rb
dpickett-clinical-0.2.1 lib/clinical/collection.rb
dpickett-clinical-0.2.10 lib/clinical/collection.rb
dpickett-clinical-0.2.3 lib/clinical/collection.rb
dpickett-clinical-0.2.4 lib/clinical/collection.rb
dpickett-clinical-0.2.5 lib/clinical/collection.rb
dpickett-clinical-0.2.6 lib/clinical/collection.rb
dpickett-clinical-0.2.7 lib/clinical/collection.rb
dpickett-clinical-0.2.8 lib/clinical/collection.rb
dpickett-clinical-0.2.9 lib/clinical/collection.rb
clinical-0.2.11 lib/clinical/collection.rb
clinical-0.2.10 lib/clinical/collection.rb
clinical-0.2.9 lib/clinical/collection.rb
clinical-0.2.8 lib/clinical/collection.rb