module Memorable::Model::ClassMethods

Public Instance Methods

build_with_params(params) click to toggle source
# File lib/memorable/model.rb, line 22
def build_with_params(params)
  instance = self.new

  # set attributes and meta data if possible
  params.each do |key, value|
    instance.send "#{key}=", value if instance.respond_to?(key)
  end

  # render content with meta data
  instance.write_content(params[:meta])
  instance
end
create_with_params!(params={}) click to toggle source
# File lib/memorable/model.rb, line 17
def create_with_params!(params={})
  instance = self.build_with_params(params)
  instance.save!
end