lib/wcc/media/series.rb in wcc-media-client-0.1.0 vs lib/wcc/media/series.rb in wcc-media-client-0.1.1
- old
+ new
@@ -1,36 +1,42 @@
module WCC
module Media
- Series =
- Struct.new(:raw) do
- def id
- raw['id']&.to_s
- end
+ class Series
+ include WCC::Media::Cacheable
- def legacy_id
- raw['legacy_id']&.to_s
- end
+ attr_reader :raw, :headers
- %w[
- title
- subtitle
- summary
- date_range
- messages_count
- ].each do |att|
- define_method att do
- raw[att]
- end
- end
+ def initialize(raw, headers = {})
+ @raw = raw
+ @headers = headers
+ end
- %w[
- images
- ].each do |att|
- define_method att do
- OpenStruct.new(raw[att]) if raw[att]
- end
+ def id
+ raw['id']&.to_s
+ end
+
+ def legacy_id
+ raw['legacy_id']&.to_s
+ end
+
+ %w[
+ title
+ subtitle
+ summary
+ date_range
+ messages_count
+ ].each do |att|
+ define_method att do
+ raw[att]
end
+ end
- undef raw=
+ %w[
+ images
+ ].each do |att|
+ define_method att do
+ OpenStruct.new(raw[att]) if raw[att]
+ end
end
+ end
end
end