acts_as_lockable 0.2.0 → 0.2.1
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:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 9d1f65e440c52da4d26577a216441a4dc9036aad
|
4
|
+
data.tar.gz: 80c8df26f287cc4e8a0360326083f3cc1759965f
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: ef5788b86d5cecd94764b2cc913dacea16065edc248dff876bac626c88bdfd1702dd735a1028b0ff64e588a167887d06a4c7e9816042d4e4f313f92b2fdca7fe
|
7
|
+
data.tar.gz: e894900d21564d686e9ce87e0800f74ffa7dcacf862a3b8f6a33595dbcf2cd9f7812f20ce73912c2ff343cc2a9e8042192fdd82a0e1dd94158cba7392e503abe
|
data/README.md
CHANGED
@@ -18,27 +18,18 @@ Or install it yourself as:
|
|
18
18
|
|
19
19
|
$ gem install acts_as_lockable
|
20
20
|
|
21
|
-
####
|
21
|
+
#### Database Migrations
|
22
22
|
|
23
23
|
Run:
|
24
24
|
|
25
25
|
``` shell
|
26
|
-
rails generate migration
|
27
|
-
|
28
|
-
|
29
|
-
and now you have a migration
|
30
|
-
|
31
|
-
``` ruby
|
32
|
-
class AddIsLockedToLockers < ActiveRecord::Migration
|
33
|
-
def change
|
34
|
-
add_column :lockers, :is_locked, :boolean
|
35
|
-
end
|
36
|
-
end
|
26
|
+
rails generate acts_as_lockable:migration
|
27
|
+
rake db:migrate
|
37
28
|
```
|
38
29
|
|
39
30
|
## Usage
|
40
31
|
|
41
|
-
####
|
32
|
+
#### Lockable Models
|
42
33
|
|
43
34
|
``` ruby
|
44
35
|
class Locker < ActiveRecord::Base
|
@@ -47,7 +38,15 @@ class Locker < ActiveRecord::Base
|
|
47
38
|
# ...
|
48
39
|
end
|
49
40
|
```
|
41
|
+
#### Example
|
42
|
+
|
43
|
+
``` ruby
|
44
|
+
lovely_locker = Locker.create
|
45
|
+
lovely_locker.lock
|
46
|
+
lovely_locker.unlock
|
47
|
+
lovely_locker.is_locked?
|
50
48
|
|
49
|
+
```
|
51
50
|
|
52
51
|
## Development
|
53
52
|
|
@@ -0,0 +1,31 @@
|
|
1
|
+
require 'rails/generators/migration'
|
2
|
+
|
3
|
+
module ActsAsLockable
|
4
|
+
class MigrationGenerator < Rails::Generators::Base
|
5
|
+
include Rails::Generators::Migration
|
6
|
+
|
7
|
+
desc "Generates migration for lockable (locks table)"
|
8
|
+
|
9
|
+
def self.orm
|
10
|
+
Rails::Generators.options[:rails][:orm]
|
11
|
+
end
|
12
|
+
|
13
|
+
def self.source_root
|
14
|
+
File.join(File.dirname(__FILE__), 'templates', (orm.to_s unless orm.class.eql?(String)) )
|
15
|
+
end
|
16
|
+
|
17
|
+
def self.orm_has_migration?
|
18
|
+
[:active_record].include? orm
|
19
|
+
end
|
20
|
+
|
21
|
+
def self.next_migration_number(path)
|
22
|
+
Time.now.utc.strftime("%Y%m%d%H%M%S")
|
23
|
+
end
|
24
|
+
|
25
|
+
def create_migration_file
|
26
|
+
if self.class.orm_has_migration?
|
27
|
+
migration_template 'migration.rb', 'db/migrate/acts_as_lockable_migration.rb'
|
28
|
+
end
|
29
|
+
end
|
30
|
+
end
|
31
|
+
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: acts_as_lockable
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.2.
|
4
|
+
version: 0.2.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- GIZIPP
|
@@ -102,6 +102,8 @@ files:
|
|
102
102
|
- lib/acts_as_lockable/lock.rb
|
103
103
|
- lib/acts_as_lockable/locker.rb
|
104
104
|
- lib/acts_as_lockable/version.rb
|
105
|
+
- lib/generators/acts_as_lockable/migration/migration_generator.rb
|
106
|
+
- lib/generators/acts_as_lockable/migration/templates/active_record/migration.rb
|
105
107
|
homepage: https://github.com/gizipp/acts_as_lockable
|
106
108
|
licenses:
|
107
109
|
- MIT
|