Sha256: 0c372714ab91e46d800d3fec5b991b3fbf70376f342d420c1e648e3db8c1e14d
Contents?: true
Size: 1.48 KB
Versions: 2
Compression:
Stored size: 1.48 KB
Contents
module Citrix module Training module Serializer class Training include Helpers::Initializer # Set attributes that can be (de)serialized. attr_accessor :attributes def serialize { name: attributes[:name], description: attributes[:description], timeZone: attributes[:timezone], times: (attributes[:dates] || []).map(&:serialize), organizers: (attributes[:organizers] || []).map(&:key), registrationSettings: { disableWebRegistration: !attributes.fetch(:web_registration, true), disableConfirmationEmail: !attributes.fetch(:confirmation_email, true), } } end def deserialize { key: attributes["trainingKey"], name: attributes["name"], description: attributes["description"], timezone: attributes["timeZone"], dates: deserialize_dates(attributes["times"] || []), web_registration: !attributes["registrationSettings"]["disableWebRegistration"], confirmation_email: !attributes["registrationSettings"]["disableConfirmationEmail"] } end private def deserialize_dates(dates) dates.map do |date| Resource::TrainingDate.new( Time.parse(date["startDate"]), Time.parse(date["endDate"]) ) end end end end end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
citrix-0.2.2 | lib/citrix/training/serializer/training.rb |
citrix-0.2.1 | lib/citrix/training/serializer/training.rb |