eco-helpers 0.6.5 → 0.6.6

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: aa7eb2714d4b0510dcc62b6b42b50835d4f5db4c
4
- data.tar.gz: 0d241a6411f68297029028633051e818e08b1d2b
3
+ metadata.gz: bca4917cf9f15ff3f6c758fae5e33713d3830cb7
4
+ data.tar.gz: e5bf71ee72f3098292004c32af8a2897d6f7b5e9
5
5
  SHA512:
6
- metadata.gz: 9d8d8b78d842472624a89de3c4a78095417f83f42b89c797a0fdd1124aaea9718dc614a448d2391c99bc2ca0a5a2b91f491d6b8656e3f5306a37a191d542b49b
7
- data.tar.gz: 66eda21ef4862e5cf470312e4dbec32540287c8a3a5b8be34b56cd0b92301f0bfd22732d2f41f5714cc0d19cdd795f419d6d07e13b21d6432f93d26243119874
6
+ metadata.gz: c7a90f27cc328d0be292f9618068d185c01fe020da49a4f343b5b40df51f2850f05625b8dab2e105f5cb6c206d4cd6188b14d8f2d297d9198221b592beffabe9
7
+ data.tar.gz: 91b9c265e0212b2662ac962b9102fff5ba82cbcd3301032430a864b847e4db8f94118cc7fa5af416bcf2153c4c42a1b96a4d8b92f59721d3e30875f3e408ac65
@@ -14,7 +14,7 @@ module Eco
14
14
  [key, h_values]
15
15
  end.to_h
16
16
 
17
- fatal("Expecting Environment object. Given: #{enviro}") if enviro && !enviro.is_a?(API::Common::Session::Environment)
17
+ fatal("Expecting Environment object. Given: #{enviro}") if enviro && !enviro.is_a?(Eco::API::Common::Session::Environment)
18
18
  @enviro = enviro
19
19
 
20
20
  policy_groups = policy_groups || @enviro&.api&.policy_groups.to_a
@@ -13,6 +13,7 @@ module Eco
13
13
  def define_defaults
14
14
  ResetLandingPageCase.new(self).process
15
15
  ToCsvCase.new(self).process
16
+ ToCsvDetailedCase.new(self).process
16
17
  EmailAsIdCase.new(self).process
17
18
  NewIdCase.new(self).process
18
19
  NewEmailCase.new(self).process
@@ -39,6 +40,7 @@ end
39
40
 
40
41
  require_relative 'default_cases/reset_landing_page_case'
41
42
  require_relative 'default_cases/to_csv_case'
43
+ require_relative 'default_cases/to_csv_detailed_case'
42
44
  require_relative 'default_cases/email_as_id_case'
43
45
  require_relative 'default_cases/new_id_case'
44
46
  require_relative 'default_cases/new_email_case'
@@ -6,6 +6,34 @@ module Eco
6
6
  ATTR_PRESENCE_METHODS = ["present", "empty", "present_all?", "present_some?"]
7
7
  ATTR_COLLECTION_METHODS = ["exclude", "remove", "attr", "attr?", "attrs", "unique_attrs", "contains"] + ATTR_PRESENCE_METHODS
8
8
 
9
+ class << self
10
+
11
+ def attr_collection (*attrs)
12
+ block = ->(method) { attrs_create_method(attrs, method) }
13
+ ATTR_COLLECTION_METHODS.each(&block)
14
+ end
15
+
16
+ def attr_presence (*attrs)
17
+ block = ->(method) { attrs_create_method(attrs, method) }
18
+ ATTR_PRESENCE_METHODS.each(&block)
19
+ end
20
+
21
+ def attrs_create_method(attrs, method)
22
+ attrs.each do |attr|
23
+ attr = attr.to_s
24
+ if method.include?("attr")
25
+ attr_method = method.sub("attr", attr)
26
+ else
27
+ attr_method = "#{attr}_#{method}"
28
+ end
29
+ define_method attr_method do |*args|
30
+ send(method, attr, *args)
31
+ end
32
+ end
33
+ end
34
+
35
+ end
36
+
9
37
  #attr_reader :kclass
10
38
 
11
39
  def initialize(data = [], klass:, factory: nil, handy: Eco::Common::Language.new)
@@ -123,31 +151,6 @@ module Eco
123
151
  self.to_a.group_by { |object| object.method(attr).call }
124
152
  end
125
153
 
126
- # class level methods
127
- def self.attr_collection (*attrs)
128
- block = ->(method) { attrs_create_method(attrs, method) }
129
- ATTR_COLLECTION_METHODS.each(&block)
130
- end
131
-
132
- def self.attr_presence (*attrs)
133
- block = ->(method) { attrs_create_method(attrs, method) }
134
- ATTR_PRESENCE_METHODS.each(&block)
135
- end
136
-
137
- def self.attrs_create_method(attrs, method)
138
- attrs.each do |attr|
139
- attr = attr.to_s
140
- if method.include?("attr")
141
- attr_method = method.sub("attr", attr)
142
- else
143
- attr_method = "#{attr}_#{method}"
144
- end
145
- define_method attr_method do |*args|
146
- send(method, attr, *args)
147
- end
148
- end
149
- end
150
-
151
154
  protected
152
155
 
153
156
  def on_change
@@ -1,3 +1,3 @@
1
1
  module Eco
2
- VERSION = "0.6.5"
2
+ VERSION = "0.6.6"
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: eco-helpers
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.6.5
4
+ version: 0.6.6
5
5
  platform: ruby
6
6
  authors:
7
7
  - Oscar Segura