Skip to content

Instantly share code, notes, and snippets.

@rcdexta
Created December 20, 2014 16:46
Show Gist options
  • Save rcdexta/2125e2e3d2748c048a6a to your computer and use it in GitHub Desktop.
Save rcdexta/2125e2e3d2748c048a6a to your computer and use it in GitHub Desktop.
Illustrating Hash19 features
class MovieOMeter
include Hash19
contains :movies
inject at: '$.movies', using: :movie_name, reference: :name,
trigger: lambda { |names| IMDB.find_all_movie_ratings names }, as: 'ratings'
inject at: '$.movies', using: :movie_name, reference: :name,
trigger: lambda { |names| Twitter.search_by_terms names }, as: 'twitter_sentiments'
end
class Movie
include Hash19
attributes :name, :year, :genre, :language, :photo_url
attribute :story_line, key: :plot
has_many :actors
has_many :shows, using: :name, trigger: ->(name) { MovieTimings.get name }
end
class Actor
include Hash19
attributes :name, :age, :character_name
has_one :photo
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment