Forum: Ruby on Rails [ANN] Integrative - for integrating ActiveRecord models with external resources

Announcement (2017-05-07): www.ruby-forum.com is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see rubyonrails.org/community and ruby-lang.org/en/community for other Rails- und Ruby-related community platforms.
183edd694338a37efc37d822250fd00e?d=identicon&s=25 netizer (Guest)
on 2016-07-12 16:47
(Received via mailing list)
As I couldn't find the library for working with external resources in
Rails, I made this gem:

https://github.com/netizer/integrative

A long time ago I thought that that's what ActiveResource id for, but:
- There is no system of associations between ActiveResource models and
ActiveRecord models
- ActiveResource has a lot of features related to modifying external
resources, but I never found it particularly useful. Usually I just want
to
"enrich" my models with some content fetched from some (usually
internal)
REST API.

To make it more clear, what you can use it for, here's an example:

  class User < ApplicationRecord
    include Integrative::Integrator

    integrates :relation, requires: [:with]
  end

  class Relation
    include Integrative::Integrated

    def self.integrative_find(ids, integration)
      Friend.where(user_id: integration.call_options[:with].id,
other_user_id: ids)
    end
  end


  User.where(public: true).integrate(:relation, with:
current_user).limit(1000)

The above code would fetch Friend models only once.


All feedback is welcome.

Krzysiek
This topic is locked and can not be replied to.