-
-
Save lenary/1084597 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class Chapter | |
include Mongoid::Document | |
field :position, :type => Integer | |
field :title, :type => String | |
field :identifier, :type => String | |
embedded_in :book | |
embeds_many :elements | |
def self.process!(git, file) | |
chapter = new | |
# Parsing of XML goes here, generating parsed_doc | |
elements = parsed_doc.css("div.chapter > *") | |
elements.each { |element| element.process! } | |
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class Element | |
include Mongoid::Document | |
include Processor | |
field :tag, :type => String | |
field :identifier, :type => String | |
field :title, :type => String | |
embedded_in :chapter | |
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
module Processor | |
def process!(markup) | |
####################### | |
# How do I gain access to the chapter object these elements are being created from here? | |
####################### | |
send("process_#{markup.name}!") | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment