13
14
15
16
17
18
19
20
21
22
23
24
25
26
|
# File 'lib/orbital_fields/markdown.rb', line 13
def markdown_fields(*fields)
fields.each do |md_field|
raise TypeError, "Argument is not a symbol" unless md_field.class == Symbol
raise NoMethodError, "Argument '#{md_field.to_s}' is not a defined field in the #{self.current_class.to_s} class" unless self.current_class.fields.include?(md_field.to_s)
clean_method_name = "clean_#{md_field.to_s}".to_sym
formatted_method_name = "formatted_#{md_field.to_s}".to_sym
define_method clean_method_name do
strip_markdown(send(md_field))
end unless method_defined? clean_method_name
define_method formatted_method_name do
markdown(send(md_field))
end unless method_defined? formatted_method_name
end
end
|