lib/cockpit/core/settings.rb in cockpit-0.2.0 vs lib/cockpit/core/settings.rb in cockpit-0.2.1
- old
+ new
@@ -170,14 +170,23 @@
def spec
@spec ||= self.class.spec(self.name, self.record_type)
end
+ def present?(key)
+ has_key?(key) && !empty?(key)
+ end
+
+ def empty?(key)
+ value = self[key]
+ value.respond_to?(:empty?) ? value.empty? : !value
+ end
+
protected
def method_missing(method, *args, &block)
if method.to_s =~ /(\w+)\?$/
- has_key?($1)
+ present?($1)
elsif has_key?(method)
Cockpit::Scope.new(self, method, *args, &block)
else
super(method, *args, &block)
end