Commit | Line | Data |
8d8356bb |
1 | --------------------------------------------------------------------- |
2 | :NOTES: |
3 | --------------------------------------------------------------------- |
4 | |
5 | purely functional means we don't have to reinstantiate Engine each time, |
6 | and IMHO there's no need even without big changes. |
7 | |
8 | We can do something like this: |
9 | |
10 | sub collapse_object { |
11 | my $self = shift; |
12 | my %storage; |
13 | $self->map_attributes(sub { $self->collapse_attribute(\%storage, @_) }); |
14 | } |
15 | |
16 | or we can make collapse_attribute return KVPs (I think that's nicer and more reusable): |
17 | |
18 | sub collapse_object { |
19 | my $self = shift; |
20 | return { |
21 | $self->map_attributes('collapse_attribute'), |
22 | __class__ => $self->object->meta->name, |
23 | }; |
24 | } |
25 | |
26 | I 100% agree, the instantiation of Engine was actually a leftover from an |
27 | early version, so I can make this more functional without too much trouble. |
28 | |
29 | --------------------------------------------------------------------- |
30 | |
31 | I am not going to do this quite yet, I think there might actually still be value to |
32 | keeping it the way it is. I want to attempt an engine extension first, before i do this. |
33 | |
34 | |
35 | |
36 | |