123456789_123456789_123456789_123456789_123456789_

Module: RSS::Maker::ITunesBaseModel

Relationships & Source Files
Extension / Inclusion / Inheritance Descendants
Extended In:
Defined in: lib/rss/maker/itunes.rb

Instance Method Summary

Instance Method Details

#def_class_accessor(klass, name, type, *args)

[ GitHub ]

  
# File 'lib/rss/maker/itunes.rb', line 7

def def_class_accessor(klass, name, type, *args)
  name = name.gsub(/-/, "_").gsub(/^itunes_/, '')
  full_name = "#{RSS::ITUNES_PREFIX}_#{name}"
  case type
  when nil
    klass.def_other_element(full_name)
  when :yes_other
    def_yes_other_accessor(klass, full_name)
  when :yes_clean_other
    def_yes_clean_other_accessor(klass, full_name)
  when :csv
    def_csv_accessor(klass, full_name)
  when :element, :attribute
    recommended_attribute_name, = *args
    klass_name = "ITunes#{Utils.to_class_name(name)}"
    klass.def_classed_element(full_name, klass_name,
                              recommended_attribute_name)
  when :elements
    plural_name, recommended_attribute_name = args
    plural_name ||= "#{name}s"
    full_plural_name = "#{RSS::ITUNES_PREFIX}_#{plural_name}"
    klass_name = "ITunes#{Utils.to_class_name(name)}"
    plural_klass_name = "ITunes#{Utils.to_class_name(plural_name)}"
    def_elements_class_accessor(klass, name, full_name, full_plural_name,
                                klass_name, plural_klass_name,
                                recommended_attribute_name)
  end
end

#def_csv_accessor(klass, full_name)

[ GitHub ]

  
# File 'lib/rss/maker/itunes.rb', line 54

def def_csv_accessor(klass, full_name)
  klass.def_csv_element(full_name)
end

#def_elements_class_accessor(klass, name, full_name, full_plural_name, klass_name, plural_klass_name, recommended_attribute_name = nil)

[ GitHub ]

  
# File 'lib/rss/maker/itunes.rb', line 58

def def_elements_class_accessor(klass, name, full_name, full_plural_name,
                                klass_name, plural_klass_name,
                                recommended_attribute_name=nil)
  if recommended_attribute_name
    klass.def_classed_elements(full_name, recommended_attribute_name,
                               plural_klass_name, full_plural_name)
  else
    klass.def_classed_element(full_plural_name, plural_klass_name)
  end
  klass.module_eval(<<-EOC, __FILE__, __LINE__ + 1)
    def new_#{full_name}(text=nil)
      #{full_name} = @#{full_plural_name}.new_#{name}
      #{full_name}.text = text
      if block_given?
        yield #{full_name}
      else
        #{full_name}
      end
    end
  EOC
end

#def_yes_clean_other_accessor(klass, full_name)

[ GitHub ]

  
# File 'lib/rss/maker/itunes.rb', line 45

def def_yes_clean_other_accessor(klass, full_name)
  klass.def_other_element(full_name)
  klass.module_eval(<<-EOC, __FILE__, __LINE__ + 1)
    def #{full_name}?
      Utils::YesCleanOther.parse(#{full_name})
    end
  EOC
end

#def_yes_other_accessor(klass, full_name)

[ GitHub ]

  
# File 'lib/rss/maker/itunes.rb', line 36

def def_yes_other_accessor(klass, full_name)
  klass.def_other_element(full_name)
  klass.module_eval(<<-EOC, __FILE__, __LINE__ + 1)
    def #{full_name}?
      Utils::YesOther.parse(@#{full_name})
    end
  EOC
end