Sha256: c151541c297207b4f682c24cb433548cab82499b0c8b1ecf7a98f212602a5e73

Contents?: true

Size: 727 Bytes

Versions: 11

Compression:

Stored size: 727 Bytes

Contents

# coding: utf-8
module Redditor
  class ContentBlock < ActiveRecord::Base

    def self.find_by_position_and_type(position, type, page_id)
      type.to_s.sub("s_attributes", "").camelcase.constantize.where(page_id: page_id, position: position).first
    end

    def self.init_by_type(type, params)
      res = type.to_s.sub("s_attributes", "").camelcase.constantize.new(params)
      res.valid?
      res
    end

    def self.check_by_position_and_type position, type, page_id
      type.to_s.sub("s_attributes", "").camelcase.constantize.where(page_id: page_id, position: position).any?
    end

    # def self.model_name
    #   ActiveModel::Name.new(self, nil, self.class.name.gsub("Redditor::", ''))
    # end

  end
end

Version data entries

11 entries across 11 versions & 1 rubygems

Version Path
redditor-0.1.10 app/models/redditor/content_block.rb
redditor-0.1.9 app/models/redditor/content_block.rb
redditor-0.1.8 app/models/redditor/content_block.rb
redditor-0.1.7 app/models/redditor/content_block.rb
redditor-0.1.6 app/models/redditor/content_block.rb
redditor-0.1.5 app/models/redditor/content_block.rb
redditor-0.1.4 app/models/redditor/content_block.rb
redditor-0.1.3 app/models/redditor/content_block.rb
redditor-0.1.2 app/models/redditor/content_block.rb
redditor-0.1.1 app/models/redditor/content_block.rb
redditor-0.1.0 app/models/redditor/content_block.rb