def_classed_elements(name, attribute, plural_class_name=nil, plural_name=nil, new_name=nil) public

No documentation

This method has no description. You can help the Ruby community by adding new notes.

Hide source
# File lib/rss/maker/base.rb, line 114
        def def_classed_elements(name, attribute, plural_class_name=nil,
                                 plural_name=nil, new_name=nil)
          plural_name ||= "#{name}s"
          new_name ||= name
          def_classed_element(plural_name, plural_class_name)
          local_variable_name = "_#{name}"
          new_value_variable_name = "new_value"
          additional_setup_code = nil
          if block_given?
            additional_setup_code = yield(local_variable_name,
                                          new_value_variable_name)
          end
          module_eval("def \#{name}\n\#{local_variable_name} = \#{plural_name}.first\n\#{local_variable_name} ? \#{local_variable_name}.\#{attribute} : nil\nend\n\ndef \#{name}=(\#{new_value_variable_name})\n\#{local_variable_name} =\n\#{plural_name}.first || \#{plural_name}.new_\#{new_name}\n\#{additional_setup_code}\n\#{local_variable_name}.\#{attribute} = \#{new_value_variable_name}\nend\n", __FILE__, __LINE__ + 1)
        end
Register or log in to add new notes.