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

obscured-timeline

Package Overview
Dependencies
Maintainers
1
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

obscured-timeline

  • 1.4.0
  • Rubygems
  • Socket score

Version published
Maintainers
1
Created
Source

Gem Version Vulnerabilities Build Status Test Coverage Code Climate

Obscured::Timeline

Introduction

Obscured timeline adds event to a separate collection for an entity (Document), the naming of the class (Mongoid Document) is used for naming the timeline collection, so if the class is named "Account" the collection name will end up being "account_timeline".

Installation

Requirements

  • activesupport
  • mongoid
  • mongoid_search
Add this line to your application's Gemfile
gem 'obscured-timeline'
Execute
$ bundle

Usage

Base

Use this in files where you create non-default log collections.

require 'obscured-timeline'

Example

Document
require 'obscured-timeline'

module Obscured
  class Account
    include Mongoid::Document
    include Mongoid::Timestamps
    include Obscured::Timeline::Tracker
    
    field :name, type: String
    field :email, type: String
    field :locked, type: Boolean, default: false
  end

  def lock!
    self.locked = true
    self.add_event(type: :security, message: "Account has been locked!", producer: self.username)
    save
  end
end


account = Obscured::Account.create(:name => "John Doe", :email => "john.doe@obscured.se")
event = account.add_event(type: :comment, message: "Lorem ipsum dolor sit amet?", producer: "homer.simpson@obscured.se")

#returns array of events for document (proprietor)
account.get_events 

#returns event by id
account.get_event(event.id.to_s)

#returns array of events by predefined params, supports pagination
account.find_events({ type: nil, producer: nil }, { limit: 20, skip: 0, order: :created_at.desc, only: [:id, :type, :message, :producer, :created_at, :updated_at, :proprietor] })

#retuns array of events
account.search_events("homer.simpson@obscured.se", { type: :comment, limit: 20, skip: 0, order: :created_at.desc }) 
Service
module Obscured
  class AccountTimelineService
    include Mongoid::Timeline::Service::Base
  end
end

module Obscured
  class AccountSynchronizer
    def initialize(account)
      @account = account
      @service = Obscured::AccountTimelineService.new
    end

    def timeline
      @service.by(proprietor: { account_id: account.id })
    end
  end
end

FAQs

Package last updated on 13 May 2021

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