forked from Veraticus/Dynamoid
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
extract duplicate code into many association
- Loading branch information
1 parent
534648a
commit d5907d3
Showing
4 changed files
with
34 additions
and
43 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Original file line | Diff line number | Diff line change |
---|---|---|---|
@@ -0,0 +1,28 @@ | |||
# encoding: utf-8 | |||
module Dynamoid #:nodoc: | |||
|
|||
module Associations | |||
module ManyAssociation | |||
|
|||
# Is this array equal to the association's records? | |||
# | |||
# @return [Boolean] true/false | |||
# | |||
# @since 0.2.0 | |||
def ==(other) | |||
records == Array(other) | |||
end | |||
|
|||
# Delegate methods we don't find directly to the records array. | |||
# | |||
# @since 0.2.0 | |||
def method_missing(method, *args) | |||
if records.respond_to?(method) | |||
records.send(method, *args) | |||
else | |||
super | |||
end | |||
end | |||
end | |||
end | |||
end |