| 
1 | 1 | # Fluid Mixins  | 
2 | 2 | 
 
  | 
3 |  | -- [register_default](#register_default)  | 
4 |  | -- [register_named](#register_named)  | 
5 |  | -- [get_default](#get_default)  | 
6 |  | -- [get_named](#get_named)  | 
7 |  | -- [apply_named](#apply_named)  | 
8 |  | -- [apply_table](#apply_table)  | 
 | 3 | +- [has_mixin](#has_mixin)  | 
 | 4 | +- [has_mixin](#has_mixin)  | 
 | 5 | +- [register_global_mixin](#register_global_mixin)  | 
 | 6 | +- [register_mixin](#register_mixin)  | 
 | 7 | +- [get_global_mixin](#get_global_mixin)  | 
 | 8 | +- [get_mixin](#get_mixin)  | 
9 | 9 | 
 
  | 
10 |  | -## register_default  | 
 | 10 | +## has_mixin  | 
11 | 11 | 
 
  | 
12 | 12 | ```lua  | 
13 |  | -fluid_mixins.register_default(class, prop[, value])  | 
 | 13 | +fluid_mixins.has_mixin(name)  | 
14 | 14 | ```  | 
15 | 15 | 
 
  | 
16 |  | -Register a mixin for a Finale class that will be applied globally. Note that methods are applied retroactively but properties will only be applied to new instances.  | 
 | 16 | +Object Method: Checks if the object it is called on has a mixin applied.  | 
17 | 17 | 
 
  | 
18 | 18 | 
 
  | 
19 | 19 | | Input | Type | Description |  | 
20 | 20 | | --- | --- | --- |  | 
21 |  | -| `class` | `string\|array` | The class (or an array of classes) to apply the mixin to. |  | 
22 |  | -| `prop` | `string\|table` | Either the property name, or a table with pairs of (string) = (mixed) |  | 
23 |  | -@ value [mixed] OPTIONAL: Method or property value. Will be ignored if prop is a table.  | 
 | 21 | +| `name` | `string` | Mixin name. |  | 
24 | 22 | 
 
  | 
25 |  | -## register_named  | 
 | 23 | +| Output type | Description |  | 
 | 24 | +| --- | --- |  | 
 | 25 | +| `boolean` |  |  | 
 | 26 | + | 
 | 27 | +## has_mixin  | 
26 | 28 | 
 
  | 
27 | 29 | ```lua  | 
28 |  | -fluid_mixins.register_named(class, mixin_name, prop[, value])  | 
 | 30 | +fluid_mixins.has_mixin(name)  | 
29 | 31 | ```  | 
30 | 32 | 
 
  | 
31 |  | -Register a named mixin which can then be applied by calling apply_named. If a named mixin requires setup, include a method called `init` that accepts zero arguments. It will be called when the mixin is applied.  | 
 | 33 | +Object Method: Applies a mixin to the object it is called on.  | 
32 | 34 | 
 
  | 
33 | 35 | 
 
  | 
34 | 36 | | Input | Type | Description |  | 
35 | 37 | | --- | --- | --- |  | 
36 |  | -| `class` | `string\|array` | The class (or an array of classes) to apply the mixin to. |  | 
37 |  | -| `mixin_name` | `string\|array` | Mixin name, or an array of names. |  | 
38 |  | -| `prop` | `string\|table` | Either the property name, or a table with pairs of (string) = (mixed) |  | 
39 |  | -@ value [mixed] OPTIONAL: Method or property value. Will be ignored if prop is a table.  | 
 | 38 | +| `name` | `string` | Mixin name. |  | 
40 | 39 | 
 
  | 
41 |  | -## get_default  | 
 | 40 | +## register_global_mixin  | 
42 | 41 | 
 
  | 
43 | 42 | ```lua  | 
44 |  | -fluid_mixins.get_default(class, prop)  | 
 | 43 | +fluid_mixins.register_global_mixin(class, prop[, value])  | 
45 | 44 | ```  | 
46 | 45 | 
 
  | 
47 |  | -Retrieves the value of a default mixin.  | 
 | 46 | +Library Method: Register a mixin for a finale class that will be applied globally (ie to all instances of the specified classes, including existing instances). Properties and methods cannot end in an underscore.  | 
48 | 47 | 
 
  | 
49 | 48 | 
 
  | 
50 | 49 | | Input | Type | Description |  | 
51 | 50 | | --- | --- | --- |  | 
52 |  | -| `class` | `string` | The Finale class name. |  | 
53 |  | -| `prop` | `string` | The name of the property or method. |  | 
54 |  | - | 
55 |  | -| Output type | Description |  | 
56 |  | -| --- | --- |  | 
57 |  | -| `mixed\|nil` | If the value is a table, a copy will be returned. |  | 
 | 51 | +| `class` | `string\|array` | The target class (or an array of classes). |  | 
 | 52 | +| `prop` | `string\|table` | Either the property name, or a table with pairs of (string) = (mixed) |  | 
 | 53 | +@ value [mixed] OPTIONAL: Method or property value. Will be ignored if prop is a table.  | 
58 | 54 | 
 
  | 
59 |  | -## get_named  | 
 | 55 | +## register_mixin  | 
60 | 56 | 
 
  | 
61 | 57 | ```lua  | 
62 |  | -fluid_mixins.get_named(class, mixin_name)  | 
 | 58 | +fluid_mixins.register_mixin(class, mixin_name, prop[, value])  | 
63 | 59 | ```  | 
64 | 60 | 
 
  | 
65 |  | -Retrieves all the methods / properties of a named mixin.  | 
 | 61 | +Library Method: Register a named mixin which can then be applied by calling the target object's apply_mixin method. If a named mixin requires a 'constructor', include a method called 'init' that accepts zero arguments. It will be called when the mixin is applied. Properties and methods cannot end in an underscore.  | 
66 | 62 | 
 
  | 
67 | 63 | 
 
  | 
68 | 64 | | Input | Type | Description |  | 
69 | 65 | | --- | --- | --- |  | 
70 |  | -| `class` | `string` | Finale class. |  | 
71 |  | -| `mixin_name` | `string` | Name of mixin. |  | 
72 |  | - | 
73 |  | -| Output type | Description |  | 
74 |  | -| --- | --- |  | 
75 |  | -| `table\|nil` |  |  | 
 | 66 | +| `class` | `string\|array` | The class (or an array of classes) to apply the mixin to. |  | 
 | 67 | +| `mixin_name` | `string\|array` | Mixin name, or an array of names. |  | 
 | 68 | +| `prop` | `string\|table` | Either the property name, or a table with pairs of (string) = (mixed) |  | 
 | 69 | +@ value [mixed] OPTIONAL: Method or property value. Will be ignored if prop is a table.  | 
76 | 70 | 
 
  | 
77 |  | -## apply_named  | 
 | 71 | +## get_global_mixin  | 
78 | 72 | 
 
  | 
79 | 73 | ```lua  | 
80 |  | -fluid_mixins.apply_named(object, mixin_name)  | 
 | 74 | +fluid_mixins.get_global_mixin(class, prop)  | 
81 | 75 | ```  | 
82 | 76 | 
 
  | 
83 |  | -Applies a named mixin to an object. See apply_table for more details.  | 
 | 77 | +Library Method: Returns a copy of all methods and properties of a global mixin.  | 
84 | 78 | 
 
  | 
85 | 79 | 
 
  | 
86 | 80 | | Input | Type | Description |  | 
87 | 81 | | --- | --- | --- |  | 
88 |  | -| `object` | `__FCBase` | The object to apply the mixin to. |  | 
89 |  | -| `mixin_name` | `string` | The name of the mixin to apply. |  | 
 | 82 | +| `class` | `string` | The finale class name. |  | 
90 | 83 | 
 
  | 
91 | 84 | | Output type | Description |  | 
92 | 85 | | --- | --- |  | 
93 |  | -| `__FCBase` | The object that was passed. |  | 
 | 86 | +| `table\|nil` |  |  | 
94 | 87 | 
 
  | 
95 |  | -## apply_table  | 
 | 88 | +## get_mixin  | 
96 | 89 | 
 
  | 
97 | 90 | ```lua  | 
98 |  | -fluid_mixins.apply_table(object, table)  | 
 | 91 | +fluid_mixins.get_mixin(class, mixin_name)  | 
99 | 92 | ```  | 
100 | 93 | 
 
  | 
101 |  | -Takes all pairs in the table and copies them over to the target object. If there is an `init` method, it will be called and then removed. This method does not check for conflicts sonit may result in another mixin's method / property being overwritten.  | 
 | 94 | +Library Method: Retrieves a copy of all the methods and properties of mixin.  | 
102 | 95 | 
 
  | 
103 | 96 | 
 
  | 
104 | 97 | | Input | Type | Description |  | 
105 | 98 | | --- | --- | --- |  | 
106 |  | -| `object` | `__FCBase` | The target object. |  | 
107 |  | -| `mixin_table` | `table` | Table of properties to apply_table |  | 
 | 99 | +| `class` | `string` | Finale class. |  | 
 | 100 | +| `mixin_name` | `string` | Name of mixin. |  | 
108 | 101 | 
 
  | 
109 | 102 | | Output type | Description |  | 
110 | 103 | | --- | --- |  | 
111 |  | -| `__FCBase` | The object that was passed. |  | 
 | 104 | +| `table\|nil` |  |  | 
0 commit comments