Class: WordPress

Inherits:
Object
  • Object
show all
Defined in:
lib/wordpress.rb,
lib/wordpress/version.rb

Defined Under Namespace

Modules: Version Classes: Base, Options

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(options) ⇒ WordPress

Returns a new instance of WordPress.



8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
# File 'lib/wordpress.rb', line 8

def initialize(options)
  # Symbolize keys
  options = options.inject({}){|memo,(k,v)| memo[k.to_sym] = v; memo}

  options[:wordpress_prefix] ||= 'wp_'
  @tbl = {
    terms: options[:wordpress_prefix] + 'terms',
    termtax: options[:wordpress_prefix] + 'term_taxonomy',
    termrel: options[:wordpress_prefix] + 'term_relationships',
    posts: options[:wordpress_prefix] + 'posts',
    postmeta: options[:wordpress_prefix] + 'postmeta',
    options: options[:wordpress_prefix] + 'options',
    prefix: options[:wordpress_prefix]
  }

  @conn = Mysql2::Client.new options
  @conn.query_options.merge!(symbolize_keys: true)

  # The WordPress options table
  @options = WP::Options.new @conn, @tbl
end

Instance Attribute Details

#optionsObject (readonly)

Returns the value of attribute options.



30
31
32
# File 'lib/wordpress.rb', line 30

def options
  @options
end