Module: HashLike
- Defined in:
- lib/wukong/extensions/emittable.rb
Instance Method Summary collapse
-
#to_flat(include_key = true) ⇒ Object
Flatten for packing as resource name followed by all fields.
Instance Method Details
#to_flat(include_key = true) ⇒ Object
Flatten for packing as resource name followed by all fields
36 37 38 39 40 41 42 43 44 45 |
# File 'lib/wukong/extensions/emittable.rb', line 36 def to_flat include_key=true if include_key.is_a? Proc sort_key = include_key.call(self) elsif include_key && respond_to?(:key) sort_key = [self.class.resource_name, key].flatten.join("-") else sort_key = self.class.resource_name end [sort_key, *to_a] # .map(&:to_flat).flatten end |