Module: LlmCostTracker::ParameterHash
- Defined in:
- lib/llm_cost_tracker/parameter_hash.rb
Class Method Summary collapse
Class Method Details
.hash_like?(value) ⇒ Boolean
6 7 8 |
# File 'lib/llm_cost_tracker/parameter_hash.rb', line 6 def hash_like?(value) value.is_a?(Hash) || action_controller_parameters?(value) end |
.to_hash(value) ⇒ Object
10 11 12 13 14 15 16 17 18 19 20 |
# File 'lib/llm_cost_tracker/parameter_hash.rb', line 10 def to_hash(value) return {} if value.nil? return value.to_unsafe_h if action_controller_parameters?(value) return value.to_h if value.is_a?(Hash) return {} unless value.respond_to?(:to_h) hash = value.to_h hash.is_a?(Hash) ? hash : {} rescue ArgumentError, TypeError {} end |
.with_indifferent_access(value) ⇒ Object
22 23 24 |
# File 'lib/llm_cost_tracker/parameter_hash.rb', line 22 def with_indifferent_access(value) to_hash(value).with_indifferent_access end |