Samenessed

The samenessed gem enables access to the sameness service ( https://github.com/avarteqgmbh/sameness ) . It provides access to the subject and principal class by connecting the sameness service's api.

Installation

Add this line to your application's Gemfile:

gem 'samenessed'

And then execute:

$ bundle

Or install it yourself as:

$ gem install samenessed

Prerequisites

Ensure to call Samenessed.load_config_file(path_to_your_config_file) before issuing any functions. You can include this line in an initializer wihtin your rails application.

Usage

You can specify the SAMENESSED_ENV environment variable to select the environment for samenessed. The default is 'development'.

Subjects (Master Identities)

Create a subject

subject = Subject.new(firstname: 'James', lastname: 'Kirk')
subject.new?  # => true
subject.save  # => true
subject.new   # => false
subject.id    # => 1

Find subjects

subject = Subject.find(1)
subject.firstname   # => 'James'
subject.id          # => 1

Delete a subject

subject = Subject.find(1)
subject.destroy   # => true
subject.exists?   # => false

Update a subject

subject = Subject.find(1)
subject.firstname = 'Ron'
subject.save  # => true

Principals (Service Identities)

Find, delete and update methods are correspond to the method descriptions above.

Create a new Principal

subject = Subject.find(1)
principal = Principal.new(account_type: "jabber", name: "[email protected]", remote_id: 123, subject_id: subject.id)
principal.exists?   # => false
principal.save      # => true
principal.exists?   # => true

Retrieve Principals of a subject

subject = Subject.find(1)
subject.principals
subject.principals.count # => 2

Retrieve Account data from another account

 = "harvest"
 = "jabber"
 = "[email protected]"
Principal.fetch_identity(, , ) # => "[email protected]"