Class: Ezframe::PrefectureType

Inherits:
SelectType show all
Defined in:
lib/ezframe/column_type.rb

Instance Attribute Summary

Attributes inherited from TypeBase

#attribute, #error, #parent

Instance Method Summary collapse

Methods inherited from SelectType

#db_type

Methods inherited from TypeBase

#db_type, #db_value, #form_html, get_class, #key, #label, #multi_inputs?, #no_edit?, #no_view?, #normalize, type_name, #validate, #value, #value=

Constructor Details

#initialize(attr) ⇒ PrefectureType

Returns a new instance of PrefectureType.



472
473
474
475
476
477
478
479
480
481
482
483
# File 'lib/ezframe/column_type.rb', line 472

def initialize(attr)
  super(attr)
  @pref_a = %w[() 北海道 青森県 岩手県 宮城県 秋田県 山形県 福島県
               茨城県 栃木県 群馬県 埼玉県 千葉県 東京都 神奈川県
               新潟県 富山県 石川県 福井県 山梨県 長野県 岐阜県 静岡県 愛知県
               三重県 滋賀県 京都府 大阪府 兵庫県 奈良県 和歌山県
               鳥取県 島根県 岡山県 広島県 山口県
               徳島県 香川県 愛媛県 高知県
               福岡県 佐賀県 長崎県 熊本県 大分県 宮崎県 鹿児島県 沖縄県]
  @pref_h = {}
  @pref_a.each_with_index { |p, i| @pref_h[i] = p }
end

Instance Method Details

#form(opts = {}) ⇒ Object



485
486
487
488
489
490
# File 'lib/ezframe/column_type.rb', line 485

def form(opts = {})
  return nil if no_edit? && !opts[:force]
  h = super
  h[:item] = @pref_h
  return h
end

#viewObject



492
493
494
495
# File 'lib/ezframe/column_type.rb', line 492

def view
  return nil if no_view? && !opts[:force]
  return @pref_h[@value.to_i]
end