Class: MongoMapper::Plugins::Callbacks::Callback
- Defined in:
- lib/mongo_mapper/plugins/callbacks.rb
Instance Attribute Summary collapse
-
#identifier ⇒ Object
readonly
Returns the value of attribute identifier.
-
#kind ⇒ Object
readonly
Returns the value of attribute kind.
-
#method ⇒ Object
readonly
Returns the value of attribute method.
-
#options ⇒ Object
readonly
Returns the value of attribute options.
Instance Method Summary collapse
- #==(other) ⇒ Object
- #call(*args, &block) ⇒ Object
- #dup ⇒ Object
- #eql?(other) ⇒ Boolean
- #hash ⇒ Object
-
#initialize(kind, method, options = {}) ⇒ Callback
constructor
A new instance of Callback.
Constructor Details
#initialize(kind, method, options = {}) ⇒ Callback
Returns a new instance of Callback.
172 173 174 175 176 177 |
# File 'lib/mongo_mapper/plugins/callbacks.rb', line 172 def initialize(kind, method, = {}) @kind = kind @method = method @identifier = [:identifier] @options = end |
Instance Attribute Details
#identifier ⇒ Object (readonly)
Returns the value of attribute identifier.
170 171 172 |
# File 'lib/mongo_mapper/plugins/callbacks.rb', line 170 def identifier @identifier end |
#kind ⇒ Object (readonly)
Returns the value of attribute kind.
170 171 172 |
# File 'lib/mongo_mapper/plugins/callbacks.rb', line 170 def kind @kind end |
#method ⇒ Object (readonly)
Returns the value of attribute method.
170 171 172 |
# File 'lib/mongo_mapper/plugins/callbacks.rb', line 170 def method @method end |
#options ⇒ Object (readonly)
Returns the value of attribute options.
170 171 172 |
# File 'lib/mongo_mapper/plugins/callbacks.rb', line 170 def @options end |
Instance Method Details
#==(other) ⇒ Object
179 180 181 182 183 184 185 186 |
# File 'lib/mongo_mapper/plugins/callbacks.rb', line 179 def ==(other) case other when Callback (self.identifier && self.identifier == other.identifier) || self.method == other.method else (self.identifier && self.identifier == other) || self.method == other end end |
#call(*args, &block) ⇒ Object
204 205 206 207 208 209 210 |
# File 'lib/mongo_mapper/plugins/callbacks.rb', line 204 def call(*args, &block) evaluate_method(method, *args, &block) if should_run_callback?(*args) rescue LocalJumpError raise ArgumentError, "Cannot yield from a Proc type filter. The Proc must take two " + "arguments and execute #call on the second argument." end |
#dup ⇒ Object
192 193 194 |
# File 'lib/mongo_mapper/plugins/callbacks.rb', line 192 def dup self.class.new(@kind, @method, @options.dup) end |
#eql?(other) ⇒ Boolean
188 189 190 |
# File 'lib/mongo_mapper/plugins/callbacks.rb', line 188 def eql?(other) self == other end |
#hash ⇒ Object
196 197 198 199 200 201 202 |
# File 'lib/mongo_mapper/plugins/callbacks.rb', line 196 def hash if @identifier @identifier.hash else @method.hash end end |