Class: Redditor::ContentBlock

Inherits:
ActiveRecord::Base
  • Object
show all
Defined in:
app/models/redditor/content_block.rb

Class Method Summary collapse

Class Method Details

.check_by_position_and_type(position, type, page_id) ⇒ Object



15
16
17
# File 'app/models/redditor/content_block.rb', line 15

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

.find_by_position_and_type(position, type, page_id) ⇒ Object



5
6
7
# File 'app/models/redditor/content_block.rb', line 5

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

.init_by_type(type, params) ⇒ Object



9
10
11
12
13
# File 'app/models/redditor/content_block.rb', line 9

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