Created
October 26, 2010 21:24
-
-
Save tcocca/647841 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
attr_accessor :features_as_hash | |
def method_missing(method_name, *args, &block) | |
name = method_name.to_s | |
if self.respond_to?(name) | |
super | |
elsif features_hash.has_key?(name) | |
return features_hash[name] | |
else | |
logger.debug("Attribute #{name} on property #{self.id} does not exist") | |
super | |
end | |
end | |
def features_hash | |
if features_as_hash.nil? | |
self.features_as_hash = {} | |
property_features.each do |prop_feature| | |
self.features_as_hash[prop_feature.feature.name] = prop_feature.value if prop_feature.feature | |
end | |
end | |
self.features_as_hash | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment