lib/bond/missions/object_mission.rb in bond-0.3.5 vs lib/bond/missions/object_mission.rb in bond-0.4.0

- old
+ new

@@ -1,16 +1,16 @@ -# 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. +# 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. +# [: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) } +# Bond.complete(:object => 'ActiveRecord::Base') {|input| input.object.class.instance_methods(false) } class Bond::ObjectMission < Bond::Mission OBJECTS = %w<\S+> + Bond::Mission::OBJECTS CONDITION = '(OBJECTS)\.(\w*(?:\?|!)?)$' def initialize(options={}) #@private @object_condition = /^#{options[:object]}$/ @@ -33,12 +33,12 @@ end def after_match(input) @completion_prefix = @matched[1] + "." @action ||= lambda {|e| default_action(e.object) } - create_input @matched[2], :object=>@evaled_object + create_input @matched[2], :object => @evaled_object end def default_action(obj) obj.methods.map {|e| e.to_s} - OPERATORS end -end \ No newline at end of file +end