single_record_interface 0.0.1 → 0.0.2

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: a33886c67f7fc94d6f73a442801f963880613772
4
- data.tar.gz: 65a5654253968f1f4c96b18858fb23bc240a3a18
3
+ metadata.gz: 1f1a03b720845857c148e40b41aa3ddf53edb529
4
+ data.tar.gz: 859c8762e6015630a914b3462df03691302c01be
5
5
  SHA512:
6
- metadata.gz: 9e99beaa48dab1091c31e06974c4410aa75ab1a9fb48ef9e764475f36885d24c94419ba4dae57fb55c3b5be37d15964c6f10a70f385d9ddb0214675622e233e3
7
- data.tar.gz: 1342c4c80c5b79b9c1a23dccd5a5639ad50f78d0aa195d22ed79d9755b000d115071752c42b0ea2e4f8e980d2efc00cf262dea79f659a18af5b595addff281f5
6
+ metadata.gz: 622ca36c85c8963464db0d5165d2f790ee49a7224d469b629684aef7b6eec0796874d9aed97c5226c9ff89f5251672e08d7c0edd035dbba065144b7acbbbda38
7
+ data.tar.gz: 2b8038f94e3d1b67c65ae5e487d8908e6af7948317ac0e226287c25aaba04e21da19cffd902bd3ab02f1d6fa5786bc3f30b31e2f22f1e4bfc9862e1d340e5e39
data/README.md CHANGED
@@ -1,8 +1,6 @@
1
1
  # SingleRecordInterface
2
2
 
3
- Welcome to your new gem! In this directory, you'll find the files you need to be able to package up your Ruby library into a gem. Put your Ruby code in the file `lib/single_record_interface`. To experiment with that code, run `bin/console` for an interactive prompt.
4
-
5
- TODO: Delete this and the text above, and describe your gem
3
+ Concern for models which should have only one record.
6
4
 
7
5
  ## Installation
8
6
 
@@ -22,20 +20,23 @@ Or install it yourself as:
22
20
 
23
21
  ## Usage
24
22
 
25
- TODO: Write usage instructions here
26
-
27
- ## Development
23
+ ```ruby
24
+ class Settings < ActiveRecord::Base
25
+ include SingleRecordInterface
26
+ end
28
27
 
29
- After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake spec` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
28
+ Settings.create(site_name: "My site")
29
+ #=> <Settings site_name: "My site" ... >
30
30
 
31
- To install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release`, which will create a git tag for the version, push git commits and tags, and push the `.gem` file to [rubygems.org](https://rubygems.org).
31
+ Settings.site_name
32
+ #=> "My site"
33
+ ```
32
34
 
33
35
  ## Contributing
34
36
 
35
- Bug reports and pull requests are welcome on GitHub at https://github.com/[USERNAME]/single_record_interface. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the [Contributor Covenant](contributor-covenant.org) code of conduct.
37
+ Bug reports and pull requests are welcome on GitHub at https://github.com/droptheplot/single_record_interface. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the [Contributor Covenant](contributor-covenant.org) code of conduct.
36
38
 
37
39
 
38
40
  ## License
39
41
 
40
42
  The gem is available as open source under the terms of the [MIT License](http://opensource.org/licenses/MIT).
41
-
@@ -5,7 +5,7 @@ module SingleRecordInterface
5
5
  include ActiveModel::Validations
6
6
 
7
7
  included do
8
- validate :only_one_record_allowed
8
+ validate :only_one_record_allowed, on: :create
9
9
 
10
10
  self.attribute_names.each do |attribute_name|
11
11
  resource = self
@@ -1,3 +1,3 @@
1
1
  module SingleRecordInterface
2
- VERSION = '0.0.1'
2
+ VERSION = '0.0.2'
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: single_record_interface
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.1
4
+ version: 0.0.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Sergey Novikov
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2016-02-29 00:00:00.000000000 Z
11
+ date: 2016-03-16 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rails