better_record 0.10.1 → 0.10.2

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
  SHA256:
3
- metadata.gz: a405b0c0c1a44d6f315d0c9f364f855b1702f8c476a1eb50d6987b97b318c1a9
4
- data.tar.gz: f3bd70fccb3de3710f73529de507052f44d946662e7889426d1ae0ac3b13a2e1
3
+ metadata.gz: 6f6c701ce3492212c79ccdf60ec86a1dea60b264c1a5e5952fe5c42b0b6eaaf7
4
+ data.tar.gz: 9614fda8762227624a58c7e34733a0bca69cc0656e28b6e166fb4010d4a27571
5
5
  SHA512:
6
- metadata.gz: cf1a31b4a42734e665b44d2cd9e40ac0a3023f99dc888bfb160982d7eabe22df3e892539e667c14d2a8b7c8d7df277c0728f02ef724de69c561fe9ecb21bfe7d
7
- data.tar.gz: c133b0a2f00e425b146a7de7822269e0c73d4c28901804ad421441cb09b28d889b3da20525a2347f1fcdc99198e74ee9135057a1ae9dd05493345d0126950cb5
6
+ metadata.gz: 9224d9d3fc1b864f0a3b7f5f0599d1f44a02740e5d0d4626476914462bb328c3fb799cdf7b6b6d6ea0046ef681ca75aedd9ca6175168140fdb753c2788919b4b
7
+ data.tar.gz: ed05b77cfe9fdf8cbd55daa38f0a96469bb0bca60ce3972d601b1d50706bdcdcaee031fcdf57e003c8f900633f4b6f5cf3815f6698d1296010efd1421edce96e
@@ -83,7 +83,7 @@ class CreateBetterRecordDBFunctions < ActiveRecord::Migration[5.2]
83
83
  SQL
84
84
 
85
85
  execute <<-SQL
86
- CREATE OR REPLACE FUNCTION unique_random_string(table_name text, column_name text, string_length integer)
86
+ CREATE OR REPLACE FUNCTION unique_random_string(table_name text, column_name text, string_length integer default 6, prefix text default '')
87
87
  RETURNS text AS
88
88
  $BODY$
89
89
  DECLARE
@@ -98,7 +98,7 @@ class CreateBetterRecordDBFunctions < ActiveRecord::Migration[5.2]
98
98
 
99
99
  LOOP
100
100
 
101
- key := '';
101
+ key := prefix;
102
102
  iterator := 0;
103
103
 
104
104
  WHILE iterator < string_length
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module BetterRecord
4
- VERSION = '0.10.1'
4
+ VERSION = '0.10.2'
5
5
  end
@@ -0,0 +1,9 @@
1
+ # frozen_string_literal: true
2
+
3
+ class Array
4
+ def to_enum
5
+ hashed = {}
6
+ each {|v| hashed[v] = v.to_s}
7
+ hashed
8
+ end
9
+ end
@@ -11,9 +11,3 @@ class Boolean
11
11
  !!parse(value)
12
12
  end
13
13
  end
14
-
15
- class Object
16
- def yes_no_to_s
17
- !!self == self ? (self ? 'yes' : 'no') : to_s
18
- end
19
- end
@@ -35,4 +35,8 @@ class Object
35
35
  puts ""
36
36
  end
37
37
  end
38
+
39
+ def yes_no_to_s
40
+ !!self == self ? (self ? 'yes' : 'no') : to_s
41
+ end
38
42
  end
@@ -7,7 +7,7 @@ class <%= migration_class_name %> < ActiveRecord::Migration[<%= ActiveRecord::Mi
7
7
  <% elsif attribute.token? -%>
8
8
  t.string :<%= attribute.name %><%= attribute.inject_options %>
9
9
  <% else -%>
10
- t.<%= attribute.type %> :<%= attribute.name %><%= attribute.type == :references ? ', null: false' : '' %><%= attribute.inject_options %>
10
+ t.<%= attribute.type %> :<%= attribute.name %><%= attribute.type.in?(%i[ references boolean ]) ? ', null: false' : '' %><%= attribute.type == :boolean ? ', default: false' : '' %><%= attribute.inject_options %>
11
11
  <% end -%>
12
12
  <% end -%>
13
13
  <% if options[:timestamps] %>
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: better_record
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.10.1
4
+ version: 0.10.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Sampson Crowley
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2018-09-01 00:00:00.000000000 Z
11
+ date: 2018-09-07 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rails
@@ -294,6 +294,7 @@ files:
294
294
  - lib/better_record/tasks/better_record/install.rake
295
295
  - lib/better_record/tasks/spec/attributes.rake
296
296
  - lib/better_record/version.rb
297
+ - lib/core_ext/array.rb
297
298
  - lib/core_ext/boolean.rb
298
299
  - lib/core_ext/object.rb
299
300
  - lib/generators/better_record/eject_rspec_extensions/USAGE