simple_form_recurring_select 0.1.0 → 0.1.1
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 +4 -4
- data/README.md +19 -19
- data/lib/simple_form_recurring_select/has_recurrence_rule.rb +1 -3
- data/lib/simple_form_recurring_select/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 242dd2751f362dedac66b8a4e0668255bc8c9de8
|
4
|
+
data.tar.gz: dceeca2f8d4e1a6c58dee50444edb3fb2699f983
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: a40bcb42f7a725d36df4f6396cef8ae6df45441687590e4ec99c9754993827ee0db4e11c76b851247ce97de3e6e33a6bc5730bd48870892ec9683f6a3b28f294
|
7
|
+
data.tar.gz: 89ff842a6fedc0087e5124a44e90c18d3bae9ee7b87da7cb848285a3081f7e1dd9f3a489c17426941d31614994b0eb931b96cef2ed8f1dd06003ae72828f3a81
|
data/README.md
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
# Simple Form Recurring Select
|
2
2
|
|
3
|
-
[](https://travis-ci.org/tomasc/simple_form_recurring_select) [](http://badge.fury.io/rb/simple_form_recurring_select) [](https://coveralls.io/r/tomasc/recurring_select)
|
4
4
|
|
5
5
|
Wrapper around the [recurring_select](https://github.com/GetJobber/recurring_select) gem for Simple Form.
|
6
6
|
|
@@ -25,41 +25,41 @@ Or install it yourself as:
|
|
25
25
|
In model:
|
26
26
|
|
27
27
|
```ruby
|
28
|
-
|
29
|
-
|
30
|
-
|
28
|
+
class MyModel
|
29
|
+
include SimpleFormRecurringSelect::HasRecurrenceRule
|
30
|
+
has_recurrence_rule
|
31
31
|
|
32
|
-
|
33
|
-
|
34
|
-
|
32
|
+
def recurrence_rule
|
33
|
+
@recurrence_rule ||= schedule.recurrence_rules.first
|
34
|
+
end
|
35
35
|
|
36
|
-
|
36
|
+
private
|
37
37
|
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
end
|
38
|
+
def update_schedule
|
39
|
+
self.schedule = IceCube::Schedule.new(schedule.start_time) do |s|
|
40
|
+
s.add_recurrence_rule(@recurrence_rule) if @recurrence_rule.present?
|
42
41
|
end
|
43
42
|
end
|
43
|
+
end
|
44
44
|
```
|
45
45
|
|
46
|
-
This will setup
|
46
|
+
This will setup `recurrence_rule` accessor that converts JSON coming from a form to [IceCube::Rule](https://github.com/seejohnrun/ice_cube). The logic of adding the recurrence rule to a schedule is left up to you.
|
47
47
|
|
48
48
|
In forms:
|
49
49
|
|
50
50
|
```ruby
|
51
|
-
|
51
|
+
= form.input :recurrence_rule, as: :recurring_select
|
52
52
|
```
|
53
53
|
|
54
54
|
## Configuration
|
55
55
|
|
56
|
-
|
56
|
+
The accessor name can be directly specified:
|
57
57
|
|
58
58
|
```ruby
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
59
|
+
class MyModel
|
60
|
+
include SimpleFormRecurringSelect::HasRecurringSelect
|
61
|
+
has_recurring_select :my_recurrence_rule
|
62
|
+
end
|
63
63
|
```
|
64
64
|
|
65
65
|
## Development
|
@@ -10,9 +10,7 @@ module SimpleFormRecurringSelect
|
|
10
10
|
# =====================================================================
|
11
11
|
|
12
12
|
module ClassMethods
|
13
|
-
def has_recurrence_rule
|
14
|
-
accessor_name = options.fetch :accessor_name, :recurrence_rule
|
15
|
-
|
13
|
+
def has_recurrence_rule accessor_name=:recurrence_rule
|
16
14
|
attr_reader accessor_name
|
17
15
|
|
18
16
|
define_method "#{accessor_name}=" do |value|
|