mad_id 0.0.2 → 0.1.0

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: 4042c8ec49b11bb1ef84bacc35e97c27424c456d
4
- data.tar.gz: cb50809eca16ed50ca04513e41e7d20e8819ba9c
3
+ metadata.gz: e038f46a789e5a30b76cf12d219cfbdedeeb71b9
4
+ data.tar.gz: 00a03911be26277c043dd5b0f047ff0761709597
5
5
  SHA512:
6
- metadata.gz: 214384a13864dec0349b7bc89b2b6dfc21299a673e83c1432aace4bf6188fcd64f9ee3887fa85b692ba937b3893ea37cdc90a98d0d6703f8b55bf73751786e36
7
- data.tar.gz: 345ea0ed4b9e90e9f4bdd472a88c02c0496e185687a619002b9e6798342f6119f1a59a713910d426d6485b9ba63a0ea29f95a92318420dccc6b073db87678933
6
+ metadata.gz: 66467e61f2ee40b9417f5fbb52eba6a0399264743fa7634f191f37ab24aaa713305006df56250a8ebd3e1b180166215120cc2112160a25d598ddddb5c7bf288c
7
+ data.tar.gz: 8ba763c6dcce3290bcbdfd02cfa63735740b711b87b58289432a787f67f67f762ede648c64ca44c9a4efe07e6f791f19f71043c63ffadd698a96892db0a842fc
@@ -0,0 +1,7 @@
1
+ module MadID::FinderMethods
2
+
3
+ def find_by_mad_id!(id)
4
+ find_by!(identifier: id.to_s.downcase)
5
+ end
6
+
7
+ end
@@ -1,4 +1,4 @@
1
- module MadId
1
+ module MadID
2
2
 
3
3
  module IdentityMethods
4
4
  extend ActiveSupport::Concern
@@ -13,7 +13,7 @@ module MadId
13
13
  end
14
14
 
15
15
  def set_identifier
16
- self.identifier = "#{self.class.object_identifier_prefix}-#{SecureRandom.uuid}"[0..34]
16
+ self.identifier = "#{self.class.object_identifier_prefix}-#{SecureRandom.uuid}"[0..34].downcase
17
17
  end
18
18
 
19
19
  def short_identifier
@@ -23,7 +23,6 @@ module MadId
23
23
  def to_param
24
24
  self.identifier
25
25
  end
26
-
27
26
  end
28
27
 
29
28
  end
@@ -1,8 +1,9 @@
1
- module MadId
1
+ module MadID
2
2
  class Railtie < ::Rails::Railtie
3
3
  initializer 'mad_id.initialize' do |app|
4
4
  ActiveSupport.on_load :active_record do
5
- ActiveRecord::Base.send(:include, MadId)
5
+ ActiveRecord::Base.send(:include, MadID)
6
+ ActiveRecord::Base.extend( MadID::FinderMethods)
6
7
  end
7
8
  end
8
9
  end
@@ -1,3 +1,3 @@
1
- module MadId
2
- VERSION = "0.0.2"
1
+ module MadID
2
+ VERSION = "0.1.0"
3
3
  end
data/lib/mad_id.rb CHANGED
@@ -4,16 +4,16 @@ require "active_record"
4
4
  require "active_support"
5
5
 
6
6
  require "mad_id/identity_methods"
7
+ require "mad_id/finder_methods"
7
8
  require "mad_id/railtie" if defined?(Rails)
8
9
 
9
- module MadId
10
+ module MadID
10
11
  extend ActiveSupport::Concern
11
12
 
12
13
  included do
13
14
  def self.identify_with(value)
14
15
  @identifier = value
15
-
16
- self.send(:include, MadId::IdentityMethods)
16
+ self.send(:include, MadID::IdentityMethods)
17
17
  end
18
18
  end
19
19
 
data/mad_id.gemspec CHANGED
@@ -5,7 +5,7 @@ require 'mad_id/version'
5
5
 
6
6
  Gem::Specification.new do |spec|
7
7
  spec.name = "mad_id"
8
- spec.version = MadId::VERSION
8
+ spec.version = MadID::VERSION
9
9
  spec.authors = ["Lars Brillert"]
10
10
  spec.email = ["lars@railslove.com"]
11
11
  spec.summary = %q{Adds prefixed identifiers to your models.}
data/spec/mad_id_spec.rb CHANGED
@@ -1,14 +1,14 @@
1
1
  require 'spec_helper'
2
2
 
3
3
  class Pony < ActiveRecord::Base
4
- include MadId
4
+ include MadID
5
5
  end
6
6
 
7
7
  class LittlePony < Pony
8
8
  identify_with :pny
9
9
  end
10
10
 
11
- describe MadId do
11
+ describe MadID do
12
12
 
13
13
  it 'inserts #identify_with' do
14
14
  expect(Pony.respond_to?(:identify_with)).to be(true)
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: mad_id
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.2
4
+ version: 0.1.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Lars Brillert
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-07-16 00:00:00.000000000 Z
11
+ date: 2014-09-22 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activerecord
@@ -121,6 +121,7 @@ files:
121
121
  - README.md
122
122
  - Rakefile
123
123
  - lib/mad_id.rb
124
+ - lib/mad_id/finder_methods.rb
124
125
  - lib/mad_id/identity_methods.rb
125
126
  - lib/mad_id/locator.rb
126
127
  - lib/mad_id/railtie.rb