Sha256: ee53864d4e5e4eba9decf643afc5849d70c214bf9e3bc71b12a3b0d43745f45a
Contents?: true
Size: 1001 Bytes
Versions: 5
Compression:
Stored size: 1001 Bytes
Contents
# # Block Model # # Stores the raw information in the database # module Annex case Annex::config[:adapter] when :activerecord class Block < ActiveRecord::Base validates_presence_of :route def self.builder(params) block = Block.where(route: "#{params[:route]}_#{params[:identifier]}").first_or_create block.content = params.try(:[], params[:content]).try(:[], params[:identifier].to_sym) return block end end when :mongoid class Block include Mongoid::Document include Mongoid::Timestamps include Mongoid::Attributes::Dynamic field :route, type: String field :content, type: Hash validates_presence_of :route def self.builder(params) block = Block.where(route: params[:route]).first_or_create block.content ||= {} params[:content].keys.each do |key| block.content[key] = params[:content][key] end return block end end end end
Version data entries
5 entries across 5 versions & 1 rubygems