Sha256: d5792000955cc205395728f381a939302f2adcc1845f9118d01d8318ba851aad
Contents?: true
Size: 775 Bytes
Versions: 1
Compression:
Stored size: 775 Bytes
Contents
class Wordsmith::Project attr_reader :name, :slug, :templates def self.all projects_attributes = Wordsmith.client.get 'projects' projects_attributes.map {|p| new(**p)} end def self.find(slug) project = all.find { |p| p.slug == slug } project or fail %Q(Project not found with slug: "#{slug}") end def schema @_schema ||= begin body = Wordsmith.client.get "projects/#{slug}" body[:schema] end end private def initialize(name: nil, slug: nil, templates: nil) raise "Missing required kword arguments" unless [name, slug, templates].all? @name = name @slug = slug @templates = Wordsmith::TemplateCollection.new( templates.map {|t| Wordsmith::Template.new project: self, **t}) end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
wordsmith-ruby-sdk-1.0.2 | lib/wordsmith/project.rb |