Skip to content

Instantly share code, notes, and snippets.

@maliqq
Forked from DanielVartanov/gist:7741198
Last active December 30, 2015 00:09
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save maliqq/7747222 to your computer and use it in GitHub Desktop.
Save maliqq/7747222 to your computer and use it in GitHub Desktop.
### Usage example
Publisher = Struct.new(:name)
Book = Struct.new(:publisher)
Review = Struct.new(:book)
def Review.publisher
book.publisher
end
def build_publisher(name)
Review.new(
Book.new(
Publisher.new(name)
))
end
reviews = [build_publisher('Publisher 1'), build_publisher('Publisher 2')]
p reviews.map(&:publisher) # => ["Publisher 1", "Publisher 2"]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment