hellobase 0.1.14 → 0.1.15

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
  SHA256:
3
- metadata.gz: 925574afb7726175b0a972403d9e805692779cbbb8f6e87ff8fbe911a135df28
4
- data.tar.gz: a2ca4330eca04f5b069e00f7c4fdcca8d245c394044c34eefd922c2619d3ce72
3
+ metadata.gz: bac093aad9f9bedcf9ca8b34666ba172cd71c967a826efcbb41c899158ec329e
4
+ data.tar.gz: 23798a5a68e2006a4df42258a0344897232c046d5c0f2c6c0fad1b50c1d712fc
5
5
  SHA512:
6
- metadata.gz: 41a29344cdece20c0f7ec4485d7db02f7297775892032763083f62fc3d823cf0253efeb09266ae50866c715cf7e089ce9215ba14cdec494d1625c63b58a514d6
7
- data.tar.gz: be6935db61dfb6320d9a3bcbb5a00b6326c27bcce4a7a850322e0aad7180fdb0fe5f49000d3791512a1a7ddc85b347e37dd21431f384f8d697b4dd4643a5177f
6
+ metadata.gz: cac0820e4e285e0b7383c0e6d1a225ec43ca28254a71cfbd1d30a6bb6cd01144ce44c47d2df9d930290b6690d456c5062c61802ba8b1e57d3a34d92e9b2bea75
7
+ data.tar.gz: 4302db7ea840217079eeb31848e13a3f92b1143b82183781c7d1e6af30447416c0d1ba0eccf442dab1898cb4588d05c25a8fd24c80d135e2edc9831bdc3280d2
@@ -7,55 +7,52 @@ require 'active_admin/inputs'
7
7
  class DatepickerWithTimeInput
8
8
  include ::Formtastic::Inputs::Base
9
9
 
10
- def self.virtual_attributes(attr)
11
- [:"_dpwt_#{attr}_d", :"_dpwt_#{attr}_h", :"_dpwt_#{attr}_m"]
10
+ def self.virtual_attributes(base)
11
+ [:"_dpwt_#{base}_d", :"_dpwt_#{base}_h", :"_dpwt_#{base}_m"]
12
12
  end
13
13
 
14
- def self.define_virtual_attributes(klass, attr)
15
- return if klass.respond_to? :_dpwt_defined
14
+ def self.define_virtual_attributes(klass, base)
15
+ attrs = virtual_attributes(base)
16
+ ivars = attrs.map {|a| :"@#{a}" }
17
+ method = :"_dpwt_set_#{base}"
16
18
 
17
- klass.class_eval <<-RUBY
18
- def self._dpwt_defined; end
19
-
20
- def _dpwt_#{attr}_d
21
- self.#{attr}&.strftime('%Y-%m-%d')
19
+ klass.class_eval do
20
+ define_method attrs[0] do
21
+ send(base)&.strftime('%Y-%m-%d')
22
22
  end
23
23
 
24
- def _dpwt_#{attr}_h
25
- self.#{attr}&.strftime('%H')
24
+ define_method attrs[1] do
25
+ send(base)&.strftime('%H')
26
26
  end
27
27
 
28
- def _dpwt_#{attr}_m
29
- self.#{attr}&.strftime('%M')
28
+ define_method attrs[2] do
29
+ send(base)&.strftime('%M')
30
30
  end
31
31
 
32
- def _dpwt_#{attr}_d=(val)
33
- @_dpwt_#{attr}_d = val
34
- _dpwt_set_#{attr}
32
+ attrs.each_with_index do |a, i|
33
+ define_method :"#{a}=" do |val|
34
+ instance_variable_set ivars[i], val
35
+ send(method)
35
36
 
36
- val
37
+ val
38
+ end
37
39
  end
38
40
 
39
- def _dpwt_#{attr}_h=(val)
40
- @_dpwt_#{attr}_h = val
41
- _dpwt_set_#{attr}
42
-
43
- val
41
+ define_method method do
42
+ send :"#{base}=",
43
+ ivars.any? {|v| instance_variable_get(v).blank? } ?
44
+ nil :
45
+ [
46
+ instance_variable_get(ivars[0]),
47
+ [
48
+ instance_variable_get(ivars[1]),
49
+ instance_variable_get(ivars[2])
50
+ ].join(':')
51
+ ].join(' ')
44
52
  end
45
53
 
46
- def _dpwt_#{attr}_m=(val)
47
- @_dpwt_#{attr}_m = val
48
- _dpwt_set_#{attr}
49
-
50
- val
51
- end
52
-
53
- private
54
-
55
- def _dpwt_set_#{attr}
56
- self.#{attr} = @_dpwt_#{attr}_d.blank? || @_dpwt_#{attr}_h.blank? || @_dpwt_#{attr}_m.blank? ? nil : [@_dpwt_#{attr}_d, [@_dpwt_#{attr}_h, @_dpwt_#{attr}_m].join(':')].join(' ')
57
- end
58
- RUBY
54
+ private method
55
+ end
59
56
  end
60
57
 
61
58
  def to_html
@@ -1,3 +1,3 @@
1
1
  module Hellobase
2
- VERSION = '0.1.14'
2
+ VERSION = '0.1.15'
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: hellobase
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.14
4
+ version: 0.1.15
5
5
  platform: ruby
6
6
  authors:
7
7
  - Anthony Wang
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2020-11-14 00:00:00.000000000 Z
11
+ date: 2020-11-16 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activeadmin