Sha256: 75ac07fa8963090250d9dab1eef95cff9d97e1d1a3d56d9608f716082d617bf9

Contents?: true

Size: 691 Bytes

Versions: 7

Compression:

Stored size: 691 Bytes

Contents

class DynamicMenu < ActiveRecord::Base
  attr_accessible :title, :dynamic_menu_id, :url, :idstr, :sort, :check_callbacks
  translates :title
  has_many :dynamic_menus
  
  validate :validate
  def validate
    self.dynamic_menu_id = 0 if self.dynamic_menu_id.to_i == 0
  end
  
  def title!
    title_str = title
    return "[#{_("no title")}]" if title_str.to_s.strip.empty?
    return title_str
  end
  
  def check_callbacks_enum
    Enumerator.new do |yielder|
      self.check_callbacks.to_s.strip.split(/\s*,\s*/).each do |str|
        yielder << str.to_s.strip.to_sym unless str.empty?
      end
    end
  end
  
  def check_callbacks?
    !check_callbacks.to_s.strip.empty?
  end
end

Version data entries

7 entries across 7 versions & 1 rubygems

Version Path
dynamic_menus-0.0.8 app/models/dynamic_menu.rb
dynamic_menus-0.0.7 app/models/dynamic_menu.rb
dynamic_menus-0.0.6 app/models/dynamic_menu.rb
dynamic_menus-0.0.5 app/models/dynamic_menu.rb
dynamic_menus-0.0.4 app/models/dynamic_menu.rb
dynamic_menus-0.0.3 app/models/dynamic_menu.rb
dynamic_menus-0.0.2 app/models/dynamic_menu.rb