Sha256: 5e0c862a6c30c346ce92091bc3fb1ed459020a27e4a25619a717edcae11adc25

Contents?: true

Size: 568 Bytes

Versions: 1

Compression:

Stored size: 568 Bytes

Contents

ImpressionistController::InstanceMethods.send(:define_method, :direct_create_statement) do |query_params={}|
	# creates a statment hash that contains default values for creating an impression.
	# if :impressionable_id is a valid ObjectId then convert it into one
	base = (defined? Moped) ? Moped::BSON : BSON
	query_params.reverse_merge!(
		:impressionable_type => controller_name.singularize.camelize,
		:impressionable_id=> !base::ObjectId.legal?(params[:id]) ? params[:id] : base::ObjectId.from_string(params[:id])
	)
	associative_create_statement(query_params)
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
impressionist-1.2.0 lib/impressionist/controllers/mongoid/impressionist_controller.rb