Class: Redmine::Base

Inherits:
ActiveResource::Base
  • Object
show all
Defined in:
lib/redmine/base.rb

Direct Known Subclasses

Issue

Constant Summary collapse

DEFAULTS =
{}

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(attributes = {}, persisted = false) ⇒ Base

Returns a new instance of Base.



8
9
10
11
12
13
14
15
# File 'lib/redmine/base.rb', line 8

def initialize(attributes = {}, persisted = false)
  self.class.site = Redmine.configuration.site

  attributes.merge!(self.class::DEFAULTS)
  attributes.merge!(Redmine.configuration.resources[self.class.element_name.to_sym] || {})

  super(attributes, persisted)
end

Class Method Details

.headersObject



17
18
19
20
21
22
# File 'lib/redmine/base.rb', line 17

def self.headers
  new_headers = static_headers.clone
  new_headers["X-Redmine-API-Key"] = Redmine.configuration.api_key

  new_headers
end

Instance Method Details

#encode(options = {}) ⇒ Object



24
25
26
# File 'lib/redmine/base.rb', line 24

def encode(options={})
  send("to_#{self.class.format.extension}", options)
end