casting_attributes 0.0.1 → 0.0.2

Sign up to get free protection for your applications and to get access to all the features.
Files changed (2) hide show
  1. data/lib/casting_attributes.rb +2 -3
  2. metadata +1 -1
@@ -5,13 +5,12 @@ module CastingAttributes
5
5
 
6
6
  module ClassMethods
7
7
  def casting_attr_reader(attr, type_name, options = {})
8
- default_value = options[:default]
9
-
10
8
  caster = _caster_by_type_name(type_name).new(self, attr)
11
9
  caster.readers.each do |reader|
12
10
  define_method reader do
13
11
  value = instance_variable_get(caster.storage_var)
14
- if !value and default_value
12
+ if value.nil? and options.key?(:default)
13
+ default_value = options[:default]
15
14
  instance_variable_set(caster.storage_var, default_value)
16
15
  value = default_value
17
16
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: casting_attributes
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.1
4
+ version: 0.0.2
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors: