activerecord-hideable 1.0.2 → 1.0.3
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: 473116b3e36e5ae79accdc9a613e79a9f12de258
|
4
|
+
data.tar.gz: 546dc7ed53c6c4d4fe7b48658f1354cff74415f0
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 30c38fb69bee9028e7b54492ff4e2223ca52f972b4587dacb8d7e21e9134ba63fe1e68772daedc84634de809fbe6c92ebd1827608bdb3805a7a4bf2f2ffad00c
|
7
|
+
data.tar.gz: cd75369acccab25b8964b903cdec7d120efe3981e5c63b300d9ed77d1853230c9a4fcfea48c5847e627453c8d29bf8d1fbac0a901bb7c3e52456f9a3e5edb729
|
@@ -3,7 +3,7 @@
|
|
3
3
|
|
4
4
|
Gem::Specification.new do |s|
|
5
5
|
s.name = 'activerecord-hideable'
|
6
|
-
s.version = '1.0.
|
6
|
+
s.version = '1.0.3'
|
7
7
|
s.authors = ['Yaroslav Konoplov']
|
8
8
|
s.email = ['eahome00@gmail.com']
|
9
9
|
s.summary = 'Toggles for ActiveRecord models'
|
@@ -16,7 +16,6 @@ Gem::Specification.new do |s|
|
|
16
16
|
s.test_files = `git ls-files -z -- {test,spec,features}/*`.split("\x0")
|
17
17
|
s.require_paths = ['lib']
|
18
18
|
|
19
|
-
s.add_dependency 'activesupport',
|
20
|
-
s.add_dependency 'activerecord',
|
21
|
-
s.add_dependency 'activerecord-traits', '~> 1.0'
|
19
|
+
s.add_dependency 'activesupport', '>= 3.0', '< 6.0'
|
20
|
+
s.add_dependency 'activerecord', '>= 3.0', '< 6.0'
|
22
21
|
end
|
@@ -3,7 +3,6 @@
|
|
3
3
|
|
4
4
|
require 'active_support/concern'
|
5
5
|
require 'active_record'
|
6
|
-
require 'activerecord-traits'
|
7
6
|
|
8
7
|
require 'activerecord-hideable/macro'
|
9
8
|
require 'activerecord-hideable/migration'
|
@@ -14,14 +13,6 @@ begin
|
|
14
13
|
rescue LoadError
|
15
14
|
end
|
16
15
|
|
17
|
-
module Hideable
|
18
|
-
class << self
|
19
|
-
attr_accessor :default_column
|
20
|
-
end
|
21
|
-
|
22
|
-
self.default_column = :hidden
|
23
|
-
end
|
24
|
-
|
25
16
|
class ActiveRecord::Base
|
26
17
|
include Hideable::Macro
|
27
18
|
end
|
@@ -4,7 +4,7 @@
|
|
4
4
|
module Essay
|
5
5
|
class ModelFeatures
|
6
6
|
def hideable?
|
7
|
-
|
7
|
+
!!active_record.hideable?
|
8
8
|
end
|
9
9
|
|
10
10
|
serialize do
|
@@ -14,7 +14,7 @@ module Essay
|
|
14
14
|
|
15
15
|
class AttributeFeatures
|
16
16
|
def toggle?
|
17
|
-
|
17
|
+
active_record.features.hideable? && attribute.name == :hidden
|
18
18
|
end
|
19
19
|
|
20
20
|
serialize do
|
@@ -5,27 +5,22 @@ module Hideable
|
|
5
5
|
module Macro
|
6
6
|
extend ActiveSupport::Concern
|
7
7
|
|
8
|
+
included { class_attribute :hideable }
|
9
|
+
|
8
10
|
module ClassMethods
|
9
11
|
#
|
10
12
|
# class Article < ActiveRecord::Base
|
11
|
-
# acts_as_hideable
|
13
|
+
# acts_as_hideable
|
12
14
|
# end
|
13
15
|
#
|
14
|
-
def acts_as_hideable
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
scope :hidden, -> { where(toggle => true) }
|
19
|
-
scope :shown, -> { where(toggle => false) }
|
20
|
-
|
21
|
-
define_method(:shown?) { !self[toggle] }
|
22
|
-
define_method(:hidden?) { !!self[toggle] } unless toggle == :hidden
|
16
|
+
def acts_as_hideable
|
17
|
+
scope :hidden, -> { where(hidden: true) }
|
18
|
+
scope :shown, -> { where(hidden: false) }
|
23
19
|
|
24
|
-
|
25
|
-
class_attribute :hideable_options, instance_accessor: false, instance_predicate: false
|
26
|
-
end
|
20
|
+
define_method(:shown?) { !hidden }
|
27
21
|
|
28
|
-
self.
|
22
|
+
self.hideable = true
|
23
|
+
nil
|
29
24
|
end
|
30
25
|
end
|
31
26
|
end
|
@@ -3,9 +3,8 @@
|
|
3
3
|
|
4
4
|
module Hideable
|
5
5
|
module Migration
|
6
|
-
def toggle(
|
7
|
-
options.reverse_merge!(null: false, default: false, index: true)
|
8
|
-
column(column_name, :boolean, options)
|
6
|
+
def toggle(options = {})
|
7
|
+
column :hidden, :boolean, options.reverse_merge!(null: false, default: false, index: true)
|
9
8
|
end
|
10
9
|
end
|
11
10
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: activerecord-hideable
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.0.
|
4
|
+
version: 1.0.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Yaroslav Konoplov
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2016-10-
|
11
|
+
date: 2016-10-23 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: activesupport
|
@@ -50,20 +50,6 @@ dependencies:
|
|
50
50
|
- - "<"
|
51
51
|
- !ruby/object:Gem::Version
|
52
52
|
version: '6.0'
|
53
|
-
- !ruby/object:Gem::Dependency
|
54
|
-
name: activerecord-traits
|
55
|
-
requirement: !ruby/object:Gem::Requirement
|
56
|
-
requirements:
|
57
|
-
- - "~>"
|
58
|
-
- !ruby/object:Gem::Version
|
59
|
-
version: '1.0'
|
60
|
-
type: :runtime
|
61
|
-
prerelease: false
|
62
|
-
version_requirements: !ruby/object:Gem::Requirement
|
63
|
-
requirements:
|
64
|
-
- - "~>"
|
65
|
-
- !ruby/object:Gem::Version
|
66
|
-
version: '1.0'
|
67
53
|
description: Toggles for ActiveRecord models
|
68
54
|
email:
|
69
55
|
- eahome00@gmail.com
|