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

rails_scopy

Package Overview
Dependencies
Maintainers
1
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

rails_scopy

  • 0.1.3
  • Rubygems
  • Socket score

Version published
Maintainers
1
Created
Source

RailsScopy

Gem Version Maintainability Build Status security Gem Coverage Status

Generate automatically scopes in your model (PostgreSQL, SQLite, MySQL, etc...)

Installation

Add this line to your application's Gemfile:

gem 'rails_scopy'

And then execute:

$ bundle

Or install it yourself as:

$ gem install rails_scopy

Usage

Include RailsScopy in each models

class User < ApplicationRecord
  include RailsScopy
end

or in the parent model

class ApplicationRecord < ActiveRecord::Base
  include RailsScopy
end

and

User.not_admin

User.first_name_contains('Test')

Scopes available

SQL typeScope methodDescription
All#{column}_eq(value)equal
All#{column}_not_eq(value)not equal
All#{column}_nullis null
All#{column}_not_nullis not null
All#{column}_presentnot null and not empty
All#{column}_blanknull or empty
Allascend_by_#{column}ascending order
Alldescend_by_#{column}descending order
boolean#{column}true
booleannot_#{column}false
json#{column}_has_key(value)key present in json
jsonnot_#{column}_has_not_key(value)key doesn't present in json
boolean#{column}true
booleannot_#{column}false
date, datetime, time#{column}_to(value)<= to
date, datetime, time#{column}_from(value)from >=
date, datetime, time#{column}_after(value)after >
date, datetime, time#{column}_before(value)< before
date, datetime, time#{column}_between(value)from >= <= to
string, text#{column}_contains(value)contains
string, text#{column}_not_contains(value)doesn't contains
string, text#{column}_starts_with(value)start with
string, text#{column}_not_starts_with(value)doesn't start with
string, text#{column}_ends_with(value)end with
string, text#{column}_not_ends_with(value)doesn't end with
string, text#{column}_length(value)length eql
string, text#{column}_between_length(value)from >= <= to (length)
integer, float#{column}_to(value)<= to
integer, float#{column}_from(value)from >=
integer, float#{column}_above(value)above >
integer, float#{column}_below(value)< below
integer, float#{column}_between(value)from >= <= to
float#{column}_scale(value)scale eql (Number of decimal digits)

Contributing

Bug reports and pull requests are welcome on GitHub at https://github.com/OpenGems/rails_scopy. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the Contributor Covenant code of conduct.

License

The gem is available as open source under the terms of the MIT License.

FAQs

Package last updated on 05 Jul 2020

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