如何为 Magritte 中的描述指定不同的 getter 和 setter 访问器?
How do I specify different getter and setter accessors for a Description in Magritte?
按照惯例,您只指定访问器:而 Magritte 对两者使用相同的名称。代码和 http://book.seaside.st 中的一些评论说它支持具有不同名称的 getter 和 setter。怎么样?
您可以使用 MAPluggableAccessor
,像这样:
descriptionMonths
<magritteDescription>
^ MANumberDescription new
priority: 30;
label: 'Months';
accessor: (MAPluggableAccessor
read: [ :this | this periodMonths ]
write: [ :this :monthsNumber | this periodMonths: monthsNumber ]);
yourself
按照惯例,您只指定访问器:而 Magritte 对两者使用相同的名称。代码和 http://book.seaside.st 中的一些评论说它支持具有不同名称的 getter 和 setter。怎么样?
您可以使用 MAPluggableAccessor
,像这样:
descriptionMonths
<magritteDescription>
^ MANumberDescription new
priority: 30;
label: 'Months';
accessor: (MAPluggableAccessor
read: [ :this | this periodMonths ]
write: [ :this :monthsNumber | this periodMonths: monthsNumber ]);
yourself