Sha256: 565386a1ee0a3be5661a7c03668275a57814122f32533065325f2d0544ad8a5d
Contents?: true
Size: 922 Bytes
Versions: 1
Compression:
Stored size: 922 Bytes
Contents
module ClassyEnum class SemanticFormBuilder < Formtastic::SemanticFormBuilder # :nodoc: all def enum_select_input(method, options) enum_class = object.send(method) if enum_class.nil? enum_class = (options[:enum_class] || method).to_s.classify.constantize rescue Error.invalid_classy_enum_object(method) options[:collection] = enum_class.select_options else Error.invalid_classy_enum_object(method) unless enum_class.is_a? ClassyEnum::Base options[:collection] = enum_class.class.superclass.select_options options[:selected] = enum_class.to_s end options[:include_blank] = false select_input(method, options) end end module Error # :nodoc: all def self.invalid_classy_enum_object(method) raise "#{method} is not a ClassyEnum object. Make sure you've added 'classy_enum_attr :#{method}' to your model" end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
classy_enum-0.7.1 | lib/classy_enum/semantic_form_builder.rb |