lazy_lazer 0.1.1 → 0.2.0

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: b0a0ff87d642e74181e1978368095eb97a70a04e
4
- data.tar.gz: 23830bf11b2f063fbb490ace0db4070dbad04850
3
+ metadata.gz: 60a5387afe075f801b80682c550567d99da5a88e
4
+ data.tar.gz: 39ebc9c0c59e3b5010d2e6d1e5dca543c2f0a494
5
5
  SHA512:
6
- metadata.gz: 3ca0d7ed68bf597c46eec6cee920eb949bf0ccb896507e387a616c92b318c02a8cedd81862a2d2989da44df3e59f8633b8c63e21eb95a52601e3745a376224c1
7
- data.tar.gz: 61aa3915c660c862acfa4bbc7525d3894ae9f834f5160349109d659e15b1bd676fc451203c3d9e955d4cc026056f539cd61909261c955195849978080442a7cc
6
+ metadata.gz: 2726ff1abd8149b613a7cc6a689d4a1c3cf3e4f67924d59af9b02cac6186afc1a6de256498ea0edcff9e427303f1d6188eb672d222ced672d4b432d928c2ebc2
7
+ data.tar.gz: c26457eb59bef476eac2c5de64c84a041bddfd212e40bfa901e7adb13dc22c578f76e3c9d79be89c1da1c4e97f5a4941632e0d180290985c619976ff425c6573
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module LazyLazer
4
- VERSION = '0.1.1'
4
+ VERSION = '0.2.0'
5
5
  end
data/lib/lazy_lazer.rb CHANGED
@@ -84,8 +84,6 @@ module LazyLazer
84
84
  # Return the value of the attribute.
85
85
  # @param [Symbol] name the attribute name
86
86
  # @raise MissingAttribute if the key was not found
87
- # @note this differs from the Rails implementation and raises {MissingAttribute} if the
88
- # attribute wasn't found.
89
87
  def read_attribute(name)
90
88
  return @_lazer_attribute_cache[name] if @_lazer_attribute_cache.key?(name)
91
89
  reload if self.class.properties.key?(name) && !fully_loaded?
@@ -97,7 +95,14 @@ module LazyLazer
97
95
  uncoerced = Utilities.lookup_default(@_lazer_attribute_source, name, options[:default])
98
96
  Utilities.transform_value(uncoerced, options[:with])
99
97
  end
100
- alias [] read_attribute
98
+
99
+ # Return the value of the attribute, returning nil if not found
100
+ # @param [Symbol] name the attribute name
101
+ def [](name)
102
+ read_attribute(name)
103
+ rescue MissingAttribute
104
+ nil
105
+ end
101
106
 
102
107
  # Update an attribute.
103
108
  # @param [Symbol] attribute the attribute to update
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: lazy_lazer
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.1
4
+ version: 0.2.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Avinash Dwarapu