Skip to content

Conversation

@amomchilov
Copy link
Contributor

...and #size and #length, to match Hash.

Since I added Forwardable anyway, we can use it to replace the manual definition of #values

@amomchilov amomchilov force-pushed the constant-time-count branch from 66fcb5a to e244306 Compare March 26, 2021 18:50
@amomchilov amomchilov marked this pull request as ready for review March 26, 2021 19:08
nil
end

def_delegators :@collection_with_parent_collection, :count, :size, :length, :values
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you delegate to the reader rather than straight to the instance variable?

specify "PropertyCollection has O(1) #count" do
property_collection = Class.new(SmartProperties::PropertyCollection) do
def collection_with_parent_collection
mock('collection').expects(:count).once
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe we should add an additional return value and below assert for that:

mock('collection').expects(:count).once.returns(42)

and

expect(property_collection.new.count).to eq(42)

And `#size` and `#length` to match `Hash`.

Since I added `Forwardable` anyway, we can use it to replace the
manual definition of `#values`
Now it tests more than just caching.
@amomchilov amomchilov force-pushed the constant-time-count branch from 6e4bde2 to b4ecfd5 Compare March 26, 2021 19:53
@amomchilov amomchilov requested a review from t6d March 26, 2021 19:54
@amomchilov
Copy link
Contributor Author

Hmmm, I think this worked on my machine. I can't figure out how to trigger a rebuild, do you have any idea? @t6d

@amomchilov
Copy link
Contributor Author

Hey @t6d, just tidying up some old open PRs. Can this be merged?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants