mongoid_ice_cube_extension 0.1.2 → 0.2.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.travis.yml +1 -1
- data/README.md +11 -0
- data/lib/mongoid_ice_cube_extension.rb +3 -2
- data/lib/mongoid_ice_cube_extension/rule.rb +30 -0
- data/lib/mongoid_ice_cube_extension/schedule.rb +3 -5
- data/lib/mongoid_ice_cube_extension/version.rb +1 -1
- metadata +3 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: bbd882873aa9c869600d59daf9a44186396c079b
|
4
|
+
data.tar.gz: e73132e64bcbe2a3976fab606880c73b10a792f6
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 5d405c390165b2e7f0fe9dd40366995205fa4670b0545d2dd13911b4733d0d58115476b0fff95aeb792f0562f53a6b72107ecdfd2e0196d590f4018d5c250f32
|
7
|
+
data.tar.gz: a9114cbadf31b6949ba11caff89b1a506099da39bfc4cdb108c8525f9f1791c0885e95fcb283fe5dde99b1f70a4ed0f76e5245e771598d1fa1c034e92dfbdf8a
|
data/.travis.yml
CHANGED
data/README.md
CHANGED
@@ -28,6 +28,17 @@ Add to Mongoid models as:
|
|
28
28
|
field :schedule, type: MongoidIceCubeExtension::Schedule
|
29
29
|
```
|
30
30
|
|
31
|
+
and
|
32
|
+
|
33
|
+
```ruby
|
34
|
+
field :schedule, type: MongoidIceCubeExtension::Rule
|
35
|
+
```
|
36
|
+
|
37
|
+
## See also
|
38
|
+
|
39
|
+
* [MongoidRecurring](https://github.com/tomasc/mongoid_recurring) for recurring DateTime fields for Mongoid models.
|
40
|
+
* [SimpleFormRecurringSelect](https://github.com/tomasc/simple_form_recurring_select) for adding `IceCube` rules via `SimpleForm` input fields
|
41
|
+
|
31
42
|
## Development
|
32
43
|
|
33
44
|
After checking out the repo, run `bin/setup` to install dependencies. Then, run `bin/console` for an interactive prompt that will allow you to experiment.
|
@@ -1,2 +1,3 @@
|
|
1
|
-
require
|
2
|
-
require
|
1
|
+
require 'mongoid_ice_cube_extension/rule'
|
2
|
+
require 'mongoid_ice_cube_extension/schedule'
|
3
|
+
require 'mongoid_ice_cube_extension/version'
|
@@ -0,0 +1,30 @@
|
|
1
|
+
require 'ice_cube'
|
2
|
+
|
3
|
+
module MongoidIceCubeExtension
|
4
|
+
class Rule
|
5
|
+
class << self
|
6
|
+
def demongoize(value)
|
7
|
+
case value
|
8
|
+
when Hash then IceCube::Rule.from_hash(value)
|
9
|
+
else value
|
10
|
+
end
|
11
|
+
end
|
12
|
+
|
13
|
+
def mongoize(value)
|
14
|
+
case value
|
15
|
+
when 'null' then nil
|
16
|
+
when IceCube::Rule then value.to_hash
|
17
|
+
when String then IceCube::Rule.from_hash(JSON.parse(value)).to_hash
|
18
|
+
else value
|
19
|
+
end
|
20
|
+
end
|
21
|
+
|
22
|
+
def evolve(value)
|
23
|
+
case value
|
24
|
+
when IceCube::Rule then value.to_hash
|
25
|
+
else value
|
26
|
+
end
|
27
|
+
end
|
28
|
+
end
|
29
|
+
end
|
30
|
+
end
|
@@ -2,27 +2,25 @@ require 'ice_cube'
|
|
2
2
|
|
3
3
|
module MongoidIceCubeExtension
|
4
4
|
class Schedule
|
5
|
-
|
6
5
|
class << self
|
7
|
-
def demongoize
|
6
|
+
def demongoize(value)
|
8
7
|
return unless value
|
9
8
|
IceCube::Schedule.from_hash(value)
|
10
9
|
end
|
11
10
|
|
12
|
-
def mongoize
|
11
|
+
def mongoize(value)
|
13
12
|
case value
|
14
13
|
when IceCube::Schedule then value.to_hash
|
15
14
|
else value
|
16
15
|
end
|
17
16
|
end
|
18
17
|
|
19
|
-
def evolve
|
18
|
+
def evolve(value)
|
20
19
|
case value
|
21
20
|
when IceCube::Schedule then value.to_hash
|
22
21
|
else value
|
23
22
|
end
|
24
23
|
end
|
25
24
|
end
|
26
|
-
|
27
25
|
end
|
28
26
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: mongoid_ice_cube_extension
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.2.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Tomas Celizna
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2016-05-07 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: mongoid
|
@@ -145,6 +145,7 @@ files:
|
|
145
145
|
- bin/console
|
146
146
|
- bin/setup
|
147
147
|
- lib/mongoid_ice_cube_extension.rb
|
148
|
+
- lib/mongoid_ice_cube_extension/rule.rb
|
148
149
|
- lib/mongoid_ice_cube_extension/schedule.rb
|
149
150
|
- lib/mongoid_ice_cube_extension/version.rb
|
150
151
|
- mongoid_ice_cube_extension.gemspec
|