IronRuby: The use of the metaprogramming feature "Method_missing"

Source: Internet
Author: User
Tags instance method

The automated test case fragment written in Openexpressapp is so readable because it is possible to use Ruby's method_missing for method invocation:

01 打开模块 "部门管理"
02 # 1 新增部门, 编码:Test  名称:自动化测试
03 添加
04 输入 "编码","Test"   #也可以用一般语句对象.动作(参数): 属性编辑 框("编码").输入("Test")
05 输入 "名称","自动化测试"
06
07 # 2 选择系统管理员再 加任意几个岗位后
08 按钮("选择岗位").弹出窗口("选择岗位管理")
09 列表.选择行("一审人 员")
10 按住Ctrl
11 列表.选择行(0)
12 列表.选择行(1)
13 释放Ctrl
14 关闭 窗口(:确认)

This article does not specifically introduce the test framework of the preparation, but want to introduce you to the use of method_missing.

Ruby method Call procedure

When you send a message to a Ruby object, the Ruby query is called with a method that has the same name as the message. There are two main ways Ruby makes a method call, Obj.method_name and Obj.send (: Method_name), which makes the method call procedure as follows:

1. Querying the instance method of the current object

2. Each module introduced by the class (after the introduction of the first lookup)

3. The parent class of the class and the modules introduced by the parent class

4. Until object class

5. If the method is not found when the method is looked up by the path above, call method_missing

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.