rubyvideo
rubyvideo copied to clipboard
Add `frozen_record` to query static data in ActiveRecord-style
This pull request adds the frozen_record gem to allow us to query the static data in an ActiveRecord-style way. This might help to implement features like #118 where we want to import/update/query data from our static YAML files.
You can do something like:
video = Static::Video.find_by(video_id: "r78H-QBkxyk")
Which will give you something like:
=>
#<Static::Video:0x00000001252a7d78
@attributes=
{"title"=>"Opening Keynote: MythBuster",
"raw_title"=>"Opening keynote by Matz: MythBuster",
"speakers"=>["Yukihiro \"Matz\" Matsumoto"],
"event_name"=>"Euruko 2022",
"published_at"=>"2022-10-20",
"description"=>
"The opening keynote by Yukihiro Matsumoto from Euruko 2022.\n\nTo watch with closed captions, view the livestream recording: https://www.youtube.com/watch?v=reVGR35H264&t=2010s",
"video_id"=>"r78H-QBkxyk"}>
Which allows you to access all the attribute like in an ActiveRecord model:
rubyvideo(dev)> video.title
=> "Opening Keynote: MythBuster"
rubyvideo(dev)> video.speakers
=> ["Yukihiro \"Matz\" Matsumoto"]
And the same for all the playlists, speakers, organizations and videos_to_ignore files we have.