New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

month_constrain

Package Overview
Dependencies
Maintainers
3
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

month_constrain

  • 1.0.0
  • Rubygems
  • Socket score

Version published
Maintainers
3
Created
Source

MonthConstrain

month_constrain is for managing columns of Date type as month information in ActiveRecord. Converts date information such as Date.new(2016, 12, 12) and "2016-01" to Date Class.

Supports Rails 4.x and 5.x releases.

Installation

Add this line to your application's Gemfile:

gem 'month_constrain'

And then execute:

$ bundle

Or install it yourself as:

$ gem install month_constrain

Usage

In your model

class Book < ApplicationRecord
  acts_as_month_constrain :published_on

  # ...
end

Create Record

e.g.

>> Client.create(published_on: '2016-01')
# => #<Client id: 1, published_on: "2016-01-01">

>> Client.create(published_on: Date.new(2016, 1, 16))
# => #<Client id: 1, published_on: "2016-01-01">

Find Record

e.g.

>> Client.published_on('2016-01')
# => #<ActiveRecord::Relation [#<Client id: 1, published_on: "2016-01-01">]>

>> Client.published_on(Date.new(2016, 1, 16))
# => #<ActiveRecord::Relation [#<Client id: 1, published_on: "2016-01-01">]>

>> Client.published_on_in(Date.new(2016, 1, 16), nil)
# => #<ActiveRecord::Relation [#<Client id: 5, published_on: "2016-01-01">, #<Client id: 6, published_on: "2016-02-01">, #<Client id: 7, published_on: "2016-03-01">]>

>> Client.published_on_in('2016-01', '2016-02')
# => #<ActiveRecord::Relation [#<Client id: 5, published_on: "2016-01-01">, #<Client id: 6, published_on: "2016-02-01">]>

Contributing

  1. Fork it ( https://github.com/speee/month_constrain/fork )
  2. Create your feature branch (git checkout -b my-new-feature)
  3. Commit your changes (git commit -am 'Add some feature')
  4. Push to the branch (git push origin my-new-feature)
  5. Create a new Pull Request

License

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

FAQs

Package last updated on 09 Dec 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