Sha256: 3241c096fcc30a99147505a6beb79ad46a09d6d7c721df7321938ed182243142

Contents?: true

Size: 1.4 KB

Versions: 1

Compression:

Stored size: 1.4 KB

Contents

# frozen_string_literal: true

class ExtraFeature < ActiveRecord::Base
  include TranslationCms::WhiteList

  scope :sorted, -> { order("#{quoted_table_name}.sort_order") }
  validates :title, presence: true

  translates :title, :subtitle, :content
  white_list :content

  AVAILABLE_STEPS = %w[step_1 step_2 step_3].freeze
  AVAILABLE_STEPS.each do |step|
    Sunrise::Config.available_locales.each do |locale|
      define_method "#{step}_title_#{locale}" do
        steps["#{step}_title_#{locale}"]
      end
      define_method "#{step}_title_#{locale}=" do |text|
        steps["#{step}_title_#{locale}"] = text
      end
    end
    define_method "#{step}_title" do
      steps["#{step}_title_#{I18n.locale}"]
    end
    define_method "#{step}_title=" do |text|
      steps["#{step}_title_#{I18n.locale}"] = text
    end
    define_method "#{step}_icon_id" do
      steps["#{step}_icon_id"]
    end
    define_method "#{step}_icon_id=" do |id|
      steps["#{step}_icon_id"] = id
    end
  end

  def service_id
    params['service_id']
  end

  def service_id=(id)
    params['service_id'] = id
  end

  def feature_id
    params['feature_id']
  end

  def feature_id=(id)
    params['feature_id'] = id
  end

  def crm_params=(serialized)
    self.params = ActiveSupport::JSON.decode(serialized)
  end

  def order_params
    {
      service_id: params['service_id'],
      extras: params['feature_id']
    }
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
translation_cms-0.1.5 app/models/extra_feature.rb