lib/dynamic_slot_object.fy in fancy-0.7.0 vs lib/dynamic_slot_object.fy in fancy-0.8.0

- old
+ new

@@ -5,18 +5,23 @@ Example: dso = DynamicSlotObject new dso name: \"Chris\" dso age: 25 dso country: \"Germany\" - dso object # => Object with slots 'name, 'age and 'country defined + + dso object # => Object with slots 'name, 'age and 'country defined """ def initialize { @object = Object new } def object { + """ + @return @Object@ with slots defined dynamically by sending messages to @self. + """ + @object metaclass read_write_slots: (@object slots) @object } def unknown_message: m with_params: p { @@ -33,18 +38,27 @@ Example: dkh = DynamicKeyHash new dkh name: \"Chris\" dkh age: 25 dkh country: \"Germany\" - dkh hash # => <['name => \"Chris\", 'age => 25, 'country => \"Germany\"]> + + dkh hash # => <['name => \"Chris\", 'age => 25, 'country => \"Germany\"]> """ def initialize: @deep (false) { + """ + @deep If @true, recursively sends @to_hash to any value passed as an argument to @self that is a @Block@ (dynamically creating nested @Hash@es). + """ + @hash = <[]> } def hash { + """ + @return @Hash@ generated dynamically by sending messages to @self. + """ + @hash } def unknown_message: m with_params: p { m to_s split: ":" . each_with_index: |slotname idx| { @@ -68,17 +82,21 @@ dva name: \"Chris\" dva age: 25 dva country: \"Germany\" dva something_else - dva array # => [['name, \"Chris\"], ['age, 25], ['country, \"Germany\"], 'something_else] + dva array # => [['name, \"Chris\"], ['age, 25], ['country, \"Germany\"], 'something_else] """ def initialize { @arr = [] } def array { + """ + @return @Array@ generated dynamically by sending messages to @self. + """ + @arr } def unknown_message: m with_params: p { if: (p size > 0) then: {