set_man 1.0.1 → 1.0.2
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.
data/README.md
CHANGED
@@ -23,26 +23,6 @@ For enable SetMan for model, you can add call `settings`.
|
|
23
23
|
|
24
24
|
end
|
25
25
|
|
26
|
-
You can set default options:
|
27
|
-
|
28
|
-
class Options < ActiveRecord::Base
|
29
|
-
|
30
|
-
self.create do |option|
|
31
|
-
option.name = :per_page
|
32
|
-
option.value = 20
|
33
|
-
option.type = :integer
|
34
|
-
end
|
35
|
-
|
36
|
-
settings do
|
37
|
-
default :site_name, "Site Name"
|
38
|
-
default :per_page, 30
|
39
|
-
end
|
40
|
-
|
41
|
-
end
|
42
|
-
|
43
|
-
Options.where(:name => :site_name).first.value #=> "Site Name"
|
44
|
-
Options.where(:name => :per_page).first.value #=> 20
|
45
|
-
|
46
26
|
For getting option, you can use `get_option`:
|
47
27
|
|
48
28
|
Options.get_option :site_name #=> "Site Name"
|
@@ -147,15 +147,6 @@ module SetMan::ActiveRecord
|
|
147
147
|
end
|
148
148
|
end
|
149
149
|
|
150
|
-
def default(name, value)
|
151
|
-
unless self.exists?(name)
|
152
|
-
self.create do |option|
|
153
|
-
option.name = name
|
154
|
-
option.value = value
|
155
|
-
end
|
156
|
-
end
|
157
|
-
end
|
158
|
-
|
159
150
|
end
|
160
151
|
|
161
152
|
module InstanceMethods
|
data/lib/set_man/version.rb
CHANGED
metadata
CHANGED
@@ -2,7 +2,7 @@
|
|
2
2
|
name: set_man
|
3
3
|
version: !ruby/object:Gem::Version
|
4
4
|
prerelease:
|
5
|
-
version: 1.0.
|
5
|
+
version: 1.0.2
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
8
8
|
- plutalov_alexey
|
@@ -43,7 +43,6 @@ files:
|
|
43
43
|
- test/set_man_active_record_class_methods_option_test.rb
|
44
44
|
- test/set_man_active_record_class_methods_options_test.rb
|
45
45
|
- test/set_man_active_record_class_methods_test.rb
|
46
|
-
- test/set_man_active_record_default_test.rb
|
47
46
|
- test/set_man_active_record_validation.rb
|
48
47
|
- test/set_man_plugin_test.rb
|
49
48
|
- test/set_man_sql_converter_test.rb
|
@@ -81,7 +80,6 @@ test_files:
|
|
81
80
|
- test/set_man_active_record_class_methods_option_test.rb
|
82
81
|
- test/set_man_active_record_class_methods_options_test.rb
|
83
82
|
- test/set_man_active_record_class_methods_test.rb
|
84
|
-
- test/set_man_active_record_default_test.rb
|
85
83
|
- test/set_man_active_record_validation.rb
|
86
84
|
- test/set_man_plugin_test.rb
|
87
85
|
- test/set_man_sql_converter_test.rb
|
@@ -1,13 +0,0 @@
|
|
1
|
-
require 'test_helper'
|
2
|
-
|
3
|
-
class SetManActiveRecordDefaultTest < ActiveSupport::TestCase
|
4
|
-
|
5
|
-
test "should set default option, if not exists" do
|
6
|
-
assert_equal "Site Name", DefaultOptions.where(:name => :site_name).first.value
|
7
|
-
end
|
8
|
-
|
9
|
-
test "shouldn't set default option, if exists do" do
|
10
|
-
assert_equal 20, DefaultOptions.where(:name => :per_page).first.value
|
11
|
-
end
|
12
|
-
|
13
|
-
end
|