Class: Bond::ObjectMission

Inherits:
Mission
  • Object
show all
Defined in:
lib/bond/missions/object_mission.rb

Overview

A mission which completes an object’s methods. For this mission to match, the condition must match and the current object must have an ancestor that matches :object. Note: To access to the current object being completed on within an action, use the input’s object attribute.

Bond.complete Options:

:action

If an action is not specified, the default action is to complete an object’s non-operator methods.

Example:
Bond.complete(:object => 'ActiveRecord::Base') {|input| input.object.class.instance_methods(false) }

Constant Summary collapse

OBJECTS =
%w<\S+> + Bond::Mission::OBJECTS
CONDITION =
'(OBJECTS)\.(\w*(?:\?|!)?)$'

Constants inherited from Mission

Mission::OPERATORS

Instance Attribute Summary

Attributes inherited from Mission

#action, #matched, #on, #place

Instance Method Summary collapse

Methods inherited from Mission

#call_action, #call_search, #condition, create, current_eval, #execute, #matches?, #name

Constructor Details

#initialize(options = {}) ⇒ ObjectMission

Returns a new instance of ObjectMission.



15
16
17
18
19
# File 'lib/bond/missions/object_mission.rb', line 15

def initialize(options={}) #@private
  @object_condition = /^#{options[:object]}$/
  options[:on] ||= Regexp.new condition_with_objects
  super
end

Instance Method Details

#match_messageObject



21
22
23
# File 'lib/bond/missions/object_mission.rb', line 21

def match_message #@private
  "Matches completion for object with ancestor matching #{@object_condition.inspect}."
end