Skip to content

Commit

Permalink
Merge pull request #26 from razeware/WEB-3436
Browse files Browse the repository at this point in the history
WEB-3426: Adding the free attribute to chapter metadata
  • Loading branch information
sammyd authored Jun 24, 2020
2 parents 93ac2f7 + 3cf6cc9 commit 5d3788a
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 3 deletions.
2 changes: 1 addition & 1 deletion app/lib/parser/chapter_metadata.rb
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ module Parser
class ChapterMetadata
include MarkdownMetadata

VALID_SIMPLE_ATTRIBUTES = %i[number title description].freeze
VALID_SIMPLE_ATTRIBUTES = %i[number title description free].freeze

attr_reader :chapter

Expand Down
5 changes: 3 additions & 2 deletions app/models/chapter.rb
Original file line number Diff line number Diff line change
Expand Up @@ -8,17 +8,18 @@ class Chapter
include Concerns::MarkdownRenderable
include Concerns::TitleCleanser

attr_accessor :title, :number, :ordinal, :description, :authors, :markdown_file, :root_path
attr_accessor :title, :number, :ordinal, :description, :authors, :markdown_file, :root_path, :free
attr_markdown :body, source: :markdown_file, file: true
validates :title, :number, :ordinal, :markdown_file, presence: true

def initialize(attributes = {})
super
@authors ||= []
@free ||= false
end

# Used for serialisation
def attributes
{ title: nil, number: nil, ordinal: nil, description: nil, body: nil, authors: [] }.stringify_keys
{ title: nil, number: nil, ordinal: nil, description: nil, body: nil, authors: [], free: false }.stringify_keys
end
end

0 comments on commit 5d3788a

Please sign in to comment.