Module: Bloomy::Utilities::Transform
- Defined in:
- lib/bloomy/utils/transform.rb
Overview
Provides consistent response transformation across all operations. Handles date parsing and wraps hashes with indifferent access.
Constant Summary collapse
- DATE_FIELDS =
Fields that should be parsed as DateTime objects
%i[ due_date created_at completed_at closed_at updated_at week_start week_end ].freeze
Instance Method Summary collapse
-
#transform_array(array) ⇒ Array<HashWithIndifferentAccess>
Transforms an array of hashes.
-
#transform_response(hash) ⇒ HashWithIndifferentAccess?
Transforms a hash response with date parsing and indifferent access.
Instance Method Details
#transform_array(array) ⇒ Array<HashWithIndifferentAccess>
Transforms an array of hashes
37 38 39 40 41 |
# File 'lib/bloomy/utils/transform.rb', line 37 def transform_array(array) return [] if array.nil? array.map { |item| transform_response(item) } end |
#transform_response(hash) ⇒ HashWithIndifferentAccess?
Transforms a hash response with date parsing and indifferent access
23 24 25 26 27 28 |
# File 'lib/bloomy/utils/transform.rb', line 23 def transform_response(hash) return nil if hash.nil? result = parse_dates(hash) HashWithIndifferentAccess.new(result) end |