Class: ButterCMS::Parsers::PostObject

Inherits:
Object
  • Object
show all
Defined in:
lib/butter_cms/parsers/post_object.rb

Class Method Summary collapse

Class Method Details

.call(post_attributes) ⇒ ButterCMS::Post

Returns the new instance of post with the associations included

Returns:



7
8
9
10
11
12
13
14
15
# File 'lib/butter_cms/parsers/post_object.rb', line 7

def self.call(post_attributes)
  updated_post_attributes = {
    'tags' => ::ButterCMS::Parsers::TagsObjects.call(post_attributes.delete('tags')),
    'categories' => ::ButterCMS::Parsers::CategoriesObjects.call(post_attributes.delete('categories')),
    'author' => ::ButterCMS::Parsers::AuthorObject.call(post_attributes.delete('author'))
  }

  ::ButterCMS::Post.new(post_attributes.merge(updated_post_attributes))
end