boolean_datepicker 0.0.1
Sign up to get free protection for your applications and to get access to all the features.
- data/README.md +0 -0
- data/db/test.sqlite3 +0 -0
- data/lib/boolean_datepicker/base.rb +31 -0
- data/lib/boolean_datepicker/rspec_matchers.rb +6 -0
- data/lib/boolean_datepicker/version.rb +3 -0
- data/lib/boolean_datepicker.rb +3 -0
- metadata +84 -0
data/README.md
ADDED
File without changes
|
data/db/test.sqlite3
ADDED
Binary file
|
@@ -0,0 +1,31 @@
|
|
1
|
+
module BooleanDatePicker
|
2
|
+
|
3
|
+
module Base
|
4
|
+
|
5
|
+
def self.included base
|
6
|
+
base.class_eval do
|
7
|
+
base.extend ClassMethods
|
8
|
+
end
|
9
|
+
end
|
10
|
+
|
11
|
+
module ClassMethods
|
12
|
+
def boolean_datepicker_on *fields
|
13
|
+
fields.each do |f|
|
14
|
+
boolean_field,date_field = f.is_a?(Array) ? [f.first,f.last] : [f,f]
|
15
|
+
send(:define_method,"boolean_datepicker_on_#{boolean_field}") do
|
16
|
+
if send("#{boolean_field}_changed?")
|
17
|
+
val = self.send("#{boolean_field}") ? Time.now : nil
|
18
|
+
date_field_name = send(:respond_to?,"date_#{date_field}=") ? "date_#{date_field}=" : "#{date_field}="
|
19
|
+
send(date_field_name,val)
|
20
|
+
end
|
21
|
+
end
|
22
|
+
before_save "boolean_datepicker_on_#{boolean_field}".to_sym
|
23
|
+
end
|
24
|
+
end
|
25
|
+
end
|
26
|
+
|
27
|
+
end
|
28
|
+
|
29
|
+
end
|
30
|
+
|
31
|
+
ActiveRecord::Base.send :include, BooleanDatePicker::Base
|
metadata
ADDED
@@ -0,0 +1,84 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: boolean_datepicker
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.1
|
5
|
+
prerelease:
|
6
|
+
platform: ruby
|
7
|
+
authors:
|
8
|
+
- Andrea Campolonghi
|
9
|
+
autorequire:
|
10
|
+
bindir: bin
|
11
|
+
cert_chain: []
|
12
|
+
date: 2012-02-08 00:00:00.000000000Z
|
13
|
+
dependencies:
|
14
|
+
- !ruby/object:Gem::Dependency
|
15
|
+
name: activerecord
|
16
|
+
requirement: &70147849026100 !ruby/object:Gem::Requirement
|
17
|
+
none: false
|
18
|
+
requirements:
|
19
|
+
- - ! '>='
|
20
|
+
- !ruby/object:Gem::Version
|
21
|
+
version: '0'
|
22
|
+
type: :development
|
23
|
+
prerelease: false
|
24
|
+
version_requirements: *70147849026100
|
25
|
+
- !ruby/object:Gem::Dependency
|
26
|
+
name: rspec-rails
|
27
|
+
requirement: &70147849025420 !ruby/object:Gem::Requirement
|
28
|
+
none: false
|
29
|
+
requirements:
|
30
|
+
- - ! '>='
|
31
|
+
- !ruby/object:Gem::Version
|
32
|
+
version: '0'
|
33
|
+
type: :development
|
34
|
+
prerelease: false
|
35
|
+
version_requirements: *70147849025420
|
36
|
+
- !ruby/object:Gem::Dependency
|
37
|
+
name: sqlite3
|
38
|
+
requirement: &70147849024760 !ruby/object:Gem::Requirement
|
39
|
+
none: false
|
40
|
+
requirements:
|
41
|
+
- - ! '>='
|
42
|
+
- !ruby/object:Gem::Version
|
43
|
+
version: '0'
|
44
|
+
type: :development
|
45
|
+
prerelease: false
|
46
|
+
version_requirements: *70147849024760
|
47
|
+
description: ''
|
48
|
+
email: acampolonghi@gmail.com
|
49
|
+
executables: []
|
50
|
+
extensions: []
|
51
|
+
extra_rdoc_files: []
|
52
|
+
files:
|
53
|
+
- db/test.sqlite3
|
54
|
+
- lib/boolean_datepicker/base.rb
|
55
|
+
- lib/boolean_datepicker/rspec_matchers.rb
|
56
|
+
- lib/boolean_datepicker/version.rb
|
57
|
+
- lib/boolean_datepicker.rb
|
58
|
+
- README.md
|
59
|
+
homepage: ''
|
60
|
+
licenses: []
|
61
|
+
post_install_message:
|
62
|
+
rdoc_options: []
|
63
|
+
require_paths:
|
64
|
+
- lib
|
65
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
66
|
+
none: false
|
67
|
+
requirements:
|
68
|
+
- - ! '>='
|
69
|
+
- !ruby/object:Gem::Version
|
70
|
+
version: '0'
|
71
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
72
|
+
none: false
|
73
|
+
requirements:
|
74
|
+
- - ! '>='
|
75
|
+
- !ruby/object:Gem::Version
|
76
|
+
version: '0'
|
77
|
+
requirements: []
|
78
|
+
rubyforge_project:
|
79
|
+
rubygems_version: 1.8.10
|
80
|
+
signing_key:
|
81
|
+
specification_version: 3
|
82
|
+
summary: When a boolean field is saved with a true value saved the datetime.
|
83
|
+
test_files: []
|
84
|
+
has_rdoc:
|