lib/much-not-given.rb in much-not-given-0.0.1 vs lib/much-not-given.rb in much-not-given-0.1.0
- old
+ new
@@ -1,4 +1,51 @@
require "much-not-given/version"
+require "much-plugin"
module MuchNotGiven
+ include MuchPlugin
+
+ plugin_class_methods do
+ def not_given
+ @not_given ||=
+ begin
+ Class.new {
+ def initialize(receiver_name)
+ @receiver_name = receiver_name
+ end
+
+ def blank?
+ true
+ end
+
+ def present?
+ false
+ end
+
+ def to_s
+ "#{@receiver_name}.not_given"
+ end
+
+ def inspect
+ to_s
+ end
+
+ def ==(other)
+ if other.is_a?(self.class)
+ true
+ else
+ super
+ end
+ end
+ }.new(self.inspect)
+ end
+ end
+
+ def not_given?(value)
+ value == not_given
+ end
+
+ def given?(value)
+ value != not_given
+ end
+ end
end