Sha256: b0cfc6d6ddb496c31e2fddccd01cf2f1b22bee786d96ff7bca63eabad9949e5e

Contents?: true

Size: 979 Bytes

Versions: 16

Compression:

Stored size: 979 Bytes

Contents

module WP25
  class Post < ActiveRecord::Base
    set_table_name 'wp_posts'
    set_primary_key 'ID'
    establish_connection configurations['wp25']
    has_many :comments, :foreign_key => 'comment_parent', :class_name => 'WP25::Comment'
    has_many :term_relationships, :foreign_key => 'object_id'
    has_many :term_taxonomies, :through => :term_relationships,
             :class_name => 'WP25::TermTaxonomy'

    def categories
      term_taxonomies.inject([]) do |list, taxonomy|
        if taxonomy.taxonomy.eql?('category')
          list << taxonomy.term.name
        end
        list
      end
    end

    def tags
      term_taxonomies.inject([]) do |list, taxonomy|
        if taxonomy.taxonomy.eql?('post_tag')
          list << taxonomy.term.name
        end
        list
      end
    end

    def comments
      WP25::Comment.find_all_by_comment_post_ID(self.ID)
    end
    
    def self.prefix=(prefix)
      set_table_name "#{prefix}_posts"
    end
  end
end

Version data entries

16 entries across 16 versions & 1 rubygems

Version Path
typo-5.5 vendor/plugins/typo_converter/lib/converters/wp25/post.rb
typo-5.4.4 vendor/plugins/typo_converter/lib/converters/wp25/post.rb
typo-5.4.3 vendor/plugins/typo_converter/lib/converters/wp25/post.rb
typo-5.4.2 vendor/plugins/typo_converter/lib/converters/wp25/post.rb
typo-5.4.1 vendor/plugins/typo_converter/lib/converters/wp25/post.rb
typo-5.4 vendor/plugins/typo_converter/lib/converters/wp25/post.rb
typo-5.0.3.98.1 vendor/plugins/typo_converter/lib/converters/wp25/post.rb
typo-5.0.3.98 vendor/plugins/typo_converter/lib/converters/wp25/post.rb
typo-5.1.2 vendor/plugins/typo_converter/lib/converters/wp25/post.rb
typo-5.1.1 vendor/plugins/typo_converter/lib/converters/wp25/post.rb
typo-5.1.3 vendor/plugins/typo_converter/lib/converters/wp25/post.rb
typo-5.1.98 vendor/plugins/typo_converter/lib/converters/wp25/post.rb
typo-5.1 vendor/plugins/typo_converter/lib/converters/wp25/post.rb
typo-5.2 vendor/plugins/typo_converter/lib/converters/wp25/post.rb
typo-5.2.98 vendor/plugins/typo_converter/lib/converters/wp25/post.rb
typo-5.3 vendor/plugins/typo_converter/lib/converters/wp25/post.rb