attribute-defaults 0.7.0 → 0.8.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (3) hide show
  1. checksums.yaml +4 -4
  2. data/lib/attribute_defaults.rb +7 -7
  3. metadata +9 -9
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: bf9c5b946be262ef1e8ad5f74098f5629620f851
4
- data.tar.gz: 4d0d742144082b0f31508739efdc7df956c72897
3
+ metadata.gz: 829a2fbfba5c83c3fc55fec964f36217b8b097c9
4
+ data.tar.gz: 77d1a01e2bf364b3dc1ece8c0a896217a051feed
5
5
  SHA512:
6
- metadata.gz: b0556e99b92acea0301b5b07dffa67cc182371e442857709d684d7d8768ad7b26dabfe602509937b22699256c3f59d3be480c48f994c13acfafc0075ebd01c7b
7
- data.tar.gz: 6a7edba3e5b1a9fbec7d384182fc05efc97e5049476b57e3d3e35bdcd43c086723b66a854aa4472258a31d7b5fb2cb4899d87c50cec906fb1c99abd46be584d1
6
+ metadata.gz: 210c073e8e58439cca6cee8ce424235326dd513fca5c2b3968f02a84f6256119ab1fd45c238df79caac313ac9433564884ecdb0a322c8df96e01fbedb872694c
7
+ data.tar.gz: e6ac571755c218c86ce5289e030d2d366035d9818071f928b52ee4b216efd5e02347c7cd10ef3767ae165d0a8d67c88b5b94753b76f80bf3b183c873897ca4b6
@@ -13,9 +13,9 @@ module ActiveRecord
13
13
  # attr_default :age do |record|
14
14
  # Time.zone.year - record.dob.year
15
15
  # end
16
- # attr_default :description, '(none)', :if => :blank
17
- # attr_default :description, '(none)', :persisted => false
18
- # attr_default :description, :default => '(none)', :persisted => false
16
+ # attr_default :description, '(none)', if: :blank
17
+ # attr_default :description, '(none)', persisted: false
18
+ # attr_default :description, default: '(none)', persisted: false
19
19
  def attr_default(sym, *args, &block)
20
20
  options = args.extract_options!
21
21
  default = options.delete(:default) || args.shift
@@ -23,7 +23,7 @@ module ActiveRecord
23
23
 
24
24
  evaluator = "__eval_attr_default_for_#{sym}".to_sym
25
25
  setter = "__set_attr_default_for_#{sym}".to_sym
26
- block ||= default.is_a?(Proc) ? default : proc { default }
26
+ block ||= default.is_a?(Proc) ? default : -> { default }
27
27
 
28
28
  after_initialize setter.to_sym
29
29
  define_method(evaluator, &block)
@@ -41,9 +41,9 @@ module ActiveRecord
41
41
  end
42
42
 
43
43
  # Default mass-assignment. Examples:
44
- # attr_defaults :description => '(none)', :age => 12
45
- # attr_defaults :description => '(none)', :age => lambda {|r| Time.zone.year - r.dob.year }
46
- # attr_defaults :description => '(none)', :age => { :default => 12, :persisted => false }
44
+ # attr_defaults description: '(none)', age: 12
45
+ # attr_defaults description: '(none)', age: ->r { Time.zone.year - r.dob.year }
46
+ # attr_defaults description: '(none)', age: { default: 12, persisted: false }
47
47
  def attr_defaults(pairs)
48
48
  pairs.each do |pair|
49
49
  attr_default *pair
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: attribute-defaults
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.7.0
4
+ version: 0.8.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Dimitrij Denissenko
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-08-04 00:00:00.000000000 Z
11
+ date: 2017-03-08 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activerecord
@@ -16,20 +16,20 @@ dependencies:
16
16
  requirements:
17
17
  - - ">="
18
18
  - !ruby/object:Gem::Version
19
- version: 4.0.0
19
+ version: 5.0.0
20
20
  - - "<"
21
21
  - !ruby/object:Gem::Version
22
- version: 5.0.0
22
+ version: 6.0.0
23
23
  type: :runtime
24
24
  prerelease: false
25
25
  version_requirements: !ruby/object:Gem::Requirement
26
26
  requirements:
27
27
  - - ">="
28
28
  - !ruby/object:Gem::Version
29
- version: 4.0.0
29
+ version: 5.0.0
30
30
  - - "<"
31
31
  - !ruby/object:Gem::Version
32
- version: 5.0.0
32
+ version: 6.0.0
33
33
  - !ruby/object:Gem::Dependency
34
34
  name: rake
35
35
  requirement: !ruby/object:Gem::Requirement
@@ -93,15 +93,15 @@ required_ruby_version: !ruby/object:Gem::Requirement
93
93
  requirements:
94
94
  - - ">="
95
95
  - !ruby/object:Gem::Version
96
- version: 2.0.0
96
+ version: 2.2.0
97
97
  required_rubygems_version: !ruby/object:Gem::Requirement
98
98
  requirements:
99
99
  - - ">="
100
100
  - !ruby/object:Gem::Version
101
- version: 1.3.6
101
+ version: '0'
102
102
  requirements: []
103
103
  rubyforge_project:
104
- rubygems_version: 2.2.2
104
+ rubygems_version: 2.6.8
105
105
  signing_key:
106
106
  specification_version: 4
107
107
  summary: Specify default values for ActiveRecord attributes