activemodel_flags 0.1.4 → 0.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: ec5495baa74e2fc37ea924393119227ff14d9bd5
|
4
|
+
data.tar.gz: 475bed55b637c128af293ac75c996583678216b5
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: df18ec27e31381585545864412467759aaf75e317ce73b29d5036d2a011ab67b0b08d5786fd6f5b4641b8c1e7f20be580febadd689931c4e330a5790da6526ae
|
7
|
+
data.tar.gz: 13a6f1f930fc01614255c6f3ede8ffbf22a394701d6be2615afa77235fba81a3cc1f4cc0b4e9714c714f98d659552d0855b1986328d2d7104763360e963238e5
|
data/.gitignore
CHANGED
@@ -128,6 +128,29 @@ module ActivemodelFlags
|
|
128
128
|
self.save!
|
129
129
|
end
|
130
130
|
|
131
|
+
|
132
|
+
def method_missing(method)
|
133
|
+
if method.to_s =~ /^has_[a-zA-Z0-9_]+\?$/
|
134
|
+
key = method.to_s.chomp("?").reverse.chomp("_sah").reverse
|
135
|
+
has?(key.to_sym)
|
136
|
+
elsif method.to_s =~ /^hasnt_[a-zA-Z0-9_]+\?$/
|
137
|
+
key = method.to_s.chomp("?").reverse.chomp("_tnsah").reverse
|
138
|
+
hasnt?(key.to_sym)
|
139
|
+
elsif method.to_s =~ /^has_[a-zA-Z0-9_]+!$/
|
140
|
+
key = method.to_s.chomp("!").reverse.chomp("_sah").reverse
|
141
|
+
has!(key.to_sym)
|
142
|
+
elsif method.to_s =~ /^hasnt_[a-zA-Z0-9_]+!$/
|
143
|
+
key = method.to_s.chomp("!").reverse.chomp("_tnsah").reverse
|
144
|
+
hasnt!(key.to_sym)
|
145
|
+
else
|
146
|
+
super
|
147
|
+
end
|
148
|
+
end
|
149
|
+
|
150
|
+
def respond_to?(method, include_private = false)
|
151
|
+
has_flag?(method.to_s) || super(method, include_private)
|
152
|
+
end
|
153
|
+
|
131
154
|
protected
|
132
155
|
|
133
156
|
def on_flag_change(old_val, new_val)
|
@@ -1,7 +1,7 @@
|
|
1
1
|
module ActivemodelFlags
|
2
2
|
class ColumnGenerator < Rails::Generators::NamedBase
|
3
3
|
include Rails::Generators::Migration
|
4
|
-
desc "Generates the migration to add a flags column to a rails model."
|
4
|
+
desc "Generates the migration to add a JSON flags column to a rails model."
|
5
5
|
source_root File.expand_path('../templates', __FILE__)
|
6
6
|
|
7
7
|
def manifest
|
@@ -28,8 +28,8 @@ module ActivemodelFlags
|
|
28
28
|
assigns[:migration_action] = "add"
|
29
29
|
assigns[:class_name] = "add_flags_fields_to_#{custom_file_name}"
|
30
30
|
assigns[:table_name] = custom_file_name
|
31
|
-
assigns[:attributes] = [Rails::Generators::GeneratedAttribute.new("flags", "
|
31
|
+
assigns[:attributes] = [Rails::Generators::GeneratedAttribute.new("flags", "json")]
|
32
32
|
end
|
33
33
|
end
|
34
34
|
end
|
35
|
-
end
|
35
|
+
end
|