Class: Hash
- Inherits:
-
Object
- Object
- Hash
- Defined in:
- lib/collection_json_serializer/core_ext/hash.rb
Instance Method Summary collapse
-
#extract_params ⇒ Object
Extract params Returns a two-key hash where the first key is :name and the second is :properties, being the latter a hash itself.
Instance Method Details
#extract_params ⇒ Object
Extract params Returns a two-key hash where the first key is :name and the second is :properties, being the latter a hash itself.
hash = { hi: { prompt: “My prompt”, value: “Hello!” } } hash.extract_params
> { name: “hi”, properties: { prompt: “My prompt”, value: “Hello!” } }
9 10 11 12 13 14 15 |
# File 'lib/collection_json_serializer/core_ext/hash.rb', line 9 def extract_params params = {} params[:name] = keys.first params[:properties] = self[keys.first] params end |