class SmartAleck::EntryCreator
Attributes
entry[R]
Public Class Methods
create(options = {})
click to toggle source
# File lib/smart_aleck/entry_creator.rb, line 10 def self.create(options = {}) new(options).entry end
new(options = {})
click to toggle source
# File lib/smart_aleck/entry_creator.rb, line 14 def initialize(options = {}) SmartAleck.verify_configured check_required_options(options, :title, :content, :categories, :user) @title = options[:title] @content = options[:content] @categories = options[:categories] @user = options[:user] populate_entry categorize_entry end
Private Instance Methods
categorize_entry()
click to toggle source
# File lib/smart_aleck/entry_creator.rb, line 35 def categorize_entry @categories.each do |category| @entry.add_category(category) end end
populate_entry()
click to toggle source
# File lib/smart_aleck/entry_creator.rb, line 26 def populate_entry @entry = SmartAleck.entry_model.create( title: @title, content: @content, category_hash: CategoryIndexer.index(@categories), user: @user ) end