Sha256: 8fee36b87c5d945f4b9c4c90ee98bbcd9057a55caf8d5155897d0ce67bb5f602
Contents?: true
Size: 935 Bytes
Versions: 2
Compression:
Stored size: 935 Bytes
Contents
require 'optionally/required' require_relative '../smart_aleck/category_indexer' module SmartAleck class EntryCreator include Optionally::Required attr_reader :entry def self.create(options = {}) new(options).entry end 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 def populate_entry @entry = SmartAleck.entry_model.create( title: @title, content: @content, category_hash: CategoryIndexer.index(@categories), user: @user ) end def categorize_entry @categories.each do |category| @entry.add_category(category) end end end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
smart_aleck-0.1.0 | lib/smart_aleck/entry_creator.rb |
smart_aleck-0.0.1 | lib/smart_aleck/entry_creator.rb |