File tree Expand file tree Collapse file tree 4 files changed +53
-11
lines changed
Expand file tree Collapse file tree 4 files changed +53
-11
lines changed Original file line number Diff line number Diff line change 44
55 - Support for Ruby 3.4.
66
7+ ## Fixed
8+
9+ - OStruct was listed as a development dependency instead of a runtime dependency.
10+ The need for OStruct has been removed entirely.
11+
712# [ 5.4.0] [ ] (2024-11-23)
813
914## Added
Original file line number Diff line number Diff line change @@ -42,7 +42,6 @@ Gem::Specification.new do |spec|
4242 'actionpack' => [ ] ,
4343 'activerecord' => [ ] ,
4444 'kramdown' => [ '~> 2.1' ] ,
45- 'ostruct' => [ '~> 0.6' ] ,
4645 'rake' => [ '~> 13.0' ] ,
4746 'rspec' => [ '~> 3.5' ] ,
4847 'rubocop' => [ '~> 1.68.0' ] ,
Original file line number Diff line number Diff line change 11# frozen_string_literal: true
22
3- require 'ostruct'
4-
53module ActiveInteraction
64 # Holds a group of inputs together for passing from {Base} to {Filter}s.
75 #
86 # @private
9- class GroupedInput < OpenStruct
7+ class GroupedInput
8+ include Comparable
9+
10+ attr_reader :data
11+ protected :data
12+
13+ def initialize ( **data )
14+ @data = data
15+ end
16+
17+ def []( key )
18+ @data [ key ]
19+ end
20+
21+ def []=( key , value )
22+ @data [ key ] = value
23+ end
24+
25+ def <=>( other )
26+ return nil unless other . is_a? ( self . class )
27+
28+ data <=> other . data
29+ end
1030 end
1131end
Original file line number Diff line number Diff line change 11RSpec . describe ActiveInteraction ::GroupedInput do
2- subject ( :grouped_input ) { described_class . new }
2+ describe '.new' do
3+ it 'adds all values to the object' do
4+ grouped_input = described_class . new ( '1' => 1 , '2' => 2 )
35
4- it 'subclasses OpenStruct' do
5- expect ( grouped_input ) . to be_an OpenStruct
6+ expect ( grouped_input [ '1' ] ) . to be 1
7+ expect ( grouped_input [ '2' ] ) . to be 2
8+ end
69 end
710
8- it 'responds to #[]' do
9- expect { grouped_input [ :key ] } . to_not raise_error
11+ describe '#[]' do
12+ it 'returns nil if the key does not exist' do
13+ grouped_input = described_class . new
14+
15+ expect ( grouped_input [ '1' ] ) . to be_nil
16+ end
17+
18+ it 'returns a value if the key exists' do
19+ grouped_input = described_class . new ( '1' => 1 )
20+
21+ expect ( grouped_input [ '1' ] ) . to be 1
22+ end
1023 end
1124
12- it 'responds to #[]=' do
13- expect { grouped_input [ :key ] = :value } . to_not raise_error
25+ describe '#[]=' do
26+ it 'sets the key does not exist' do
27+ grouped_input = described_class . new
28+
29+ expect ( grouped_input [ '1' ] = 1 ) . to be 1
30+ expect ( grouped_input [ '1' ] ) . to be 1
31+ end
1432 end
1533end
You can’t perform that action at this time.
0 commit comments