Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add .find_by_object interface to findable #104

Merged
merged 1 commit into from
Mar 23, 2017
Merged

Conversation

abunashir
Copy link
Member

@abunashir abunashir commented Mar 23, 2017

This commit adds find_by_object method to the findable interface, so now if any class extends findable module then it will have 2 methods find and find_by_object, which can be use to initialize a new instance of the class.

The find interface expect us to provide the resource_id, and the find_by_object expect us to provide the object and it will extract the resource_id from that. Sample use cases.

order = Digicert::Order.find_by_object(Digicert::Order.all.first)

# Duplicate the order
order.duplicate

Note: We are already extending this module in Digicert::Order, so it should already have this behavior, but if you need the instantiating behavior to any other class then please extend the Digicert::Findable module.

This commit adds `find_by_object` method to the findable interface,
so now if any class extends `findable` module then it will have 2
methods `find` and `find_by_object`, which can be use to initialize
a new instance of the class.

The `find` interface expect us to provide the `resource_id`, and
the `find_by_object` expect us to provide the `object` and it will
extract the `resource_id` from that. Sample use cases.

```ruby
order = Digicert::Order.find_by_object(Digicert::Order.all.first)
order.duplicate
```
@abunashir
Copy link
Member Author

Added PR #103 !

@abunashir abunashir merged commit c3e8051 into master Mar 23, 2017
@abunashir abunashir deleted the find-by-object branch March 23, 2017 07:33
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.

1 participant