Created
February 25, 2010 03:38
-
-
Save spastorino/314204 to your computer and use it in GitHub Desktop.
*_select for date_helper
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
module ActionView | |
module Helpers | |
module DateHelper | |
[:second, :minute, :hour, :day, :month, :year].each do |name| | |
self.module_eval(<<-EOS) | |
def #{name.to_s}_select(object_name, method, options = {}, html_options = {}) | |
InstanceTag.new(object_name, method, self, options.delete(:object)).to_#{name.to_s}_select_tag(options, html_options) | |
end | |
EOS | |
end | |
end | |
class InstanceTag | |
[:second, :minute, :hour, :day, :month, :year].each do |name| | |
self.class_eval(<<-EOS) | |
def to_#{name.to_s}_select_tag(options = {}, html_options = {}) | |
datetime_selector(options, html_options).select_#{name.to_s}.html_safe! | |
end | |
EOS | |
end | |
end | |
class FormBuilder | |
[:second, :minute, :hour, :day, :month, :year].each do |name| | |
self.class_eval(<<-EOS) | |
def #{name.to_s}_select(method, options = {}, html_options = {}) | |
@template.#{name.to_s}_select(@object_name, method, objectify_options(options), html_options) | |
end | |
EOS | |
end | |
end | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment