Sha256: 7d3beb84450cc419aa9ea6289df380ab3942fc8f2efaa4c2663f63fba22a4142

Contents?: true

Size: 769 Bytes

Versions: 11

Compression:

Stored size: 769 Bytes

Contents

module Flexite
  class Entry < ActiveRecord::Base
    include WithHistory

    attr_accessible :value
    history_attributes :value

    belongs_to :parent, polymorphic: true, touch: true
    has_many :histories, as: :entity, dependent: :destroy

    before_save :check_value, :cast_value

    def self.form(attributes = {})
      Form.new(attributes)
    end

    def self.service(type)
      "entry_#{type}".to_sym
    end

    alias :form_attributes :attributes

    def t_node
      {
        'value' => self[:value],
        'type' => I18n.t("models.#{self.class.name.demodulize.underscore}"),
        'class' => self.class.name
      }
    end

    private

    def cast_value
      self[:value] = self[:value].to_s
    end

    def check_value
    end
  end
end

Version data entries

11 entries across 11 versions & 1 rubygems

Version Path
flexite-0.0.18 app/models/flexite/entry.rb
flexite-0.0.17 app/models/flexite/entry.rb
flexite-0.0.16 app/models/flexite/entry.rb
flexite-0.0.15 app/models/flexite/entry.rb
flexite-0.0.14 app/models/flexite/entry.rb
flexite-0.0.13 app/models/flexite/entry.rb
flexite-0.0.12 app/models/flexite/entry.rb
flexite-0.0.11 app/models/flexite/entry.rb
flexite-0.0.10 app/models/flexite/entry.rb
flexite-0.0.9 app/models/flexite/entry.rb
flexite-0.0.8 app/models/flexite/entry.rb