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 +4 -4
- data/lib/lazy_lazer/version.rb +1 -1
- data/lib/lazy_lazer.rb +8 -3
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 60a5387afe075f801b80682c550567d99da5a88e
|
4
|
+
data.tar.gz: 39ebc9c0c59e3b5010d2e6d1e5dca543c2f0a494
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 2726ff1abd8149b613a7cc6a689d4a1c3cf3e4f67924d59af9b02cac6186afc1a6de256498ea0edcff9e427303f1d6188eb672d222ced672d4b432d928c2ebc2
|
7
|
+
data.tar.gz: c26457eb59bef476eac2c5de64c84a041bddfd212e40bfa901e7adb13dc22c578f76e3c9d79be89c1da1c4e97f5a4941632e0d180290985c619976ff425c6573
|
data/lib/lazy_lazer/version.rb
CHANGED
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
|
-
|
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
|