Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

has_integrations

Package Overview
Dependencies
Maintainers
1
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

has_integrations

  • 0.0.1
  • Rubygems
  • Socket score

Version published
Maintainers
1
Created
Source

has_integrations

Rails gem for a pattern to manage 3rd party service integrations

Install

gem 'has_integrations'

or

gem install has_integrations

Once the gem is installed, in your app, run

rails generate has_integrations:install

Which will set up the Integration Model and a migration for the Integration model.

Usage

class User < ApplicationRecord
  # ...

  has_many :integrations,
    dependent: :destroy, extend: HasIntegrations,
    as: :owner

  # ...
end

Working with Integrations

# Get Stripe Integration.
stripe_integration = user.integrations[:stripe]

# Set Stripe Integration.
# This will create and save a new integration
# if there wasn't already a stripe integration record.
user.integrations[:stripe] = { "livemode" => false, "stripe_user_id" => 1 }

# Check if an Integration exists.
user.integrations.has?(:stripe)
# => true or false

This gem assumes each owning object can only have one type of each integration.

Configuration

In config/initializers/has_integrations.rb:

HasIntegrations.encryption_key = 'my great key'

Used for attr_encrypted on the config column

Validations

With the built in Integration class, you can monkey patch to add validations / whatever other logic.

TODO

  • Allow the generate to be passed an existing Integration class. This may be a weird config option, because the Integration class needs kind, encrypted_config, owner_id, and owner_type -- would all these columns need to be configurable?

Contributing

  • Fork
  • Open a PR
  • :-)

FAQs

Package last updated on 16 Sep 2016

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc