Class: Paperlex::Slaw
- Inherits:
-
Base
- Object
- Hashie::Dash
- Base
- Paperlex::Slaw
show all
- Extended by:
- ActiveSupport::Autoload
- Includes:
- RootObject
- Defined in:
- lib/paperlex/slaw.rb,
lib/paperlex/slaw/versions.rb
Defined Under Namespace
Classes: Versions
Class Method Summary
collapse
Instance Method Summary
collapse
Methods included from RootObject
#save!
Methods inherited from Base
[], delete, get, #initialize, parse, post, put, #to_uuid
Constructor Details
This class inherits a constructor from Paperlex::Base
Class Method Details
.create(attrs = {}) ⇒ Object
24
25
26
27
28
29
|
# File 'lib/paperlex/slaw.rb', line 24
def create(attrs = {})
attrs.symbolize_keys!
attrs.assert_valid_keys(create_fields)
attrs = post(collection_url, :slaw => attrs)
new(attrs)
end
|
.update_fields ⇒ Object
Also known as:
create_fields
19
20
21
|
# File 'lib/paperlex/slaw.rb', line 19
def update_fields
[:name, :body, :description]
end
|
.url_name ⇒ Object
15
16
17
|
# File 'lib/paperlex/slaw.rb', line 15
def url_name
"slaws"
end
|
Instance Method Details
#at_version(version_index) ⇒ Object
Also known as:
version_at
51
52
53
|
# File 'lib/paperlex/slaw.rb', line 51
def at_version(version_index)
self.class.new(Paperlex::Slaw::Versions[uuid].find(version_index))
end
|
#destroy ⇒ Object
42
43
44
|
# File 'lib/paperlex/slaw.rb', line 42
def destroy
self.class.delete(self.class.url_for(uuid))
end
|
#html_url(responses = nil, options = {}) ⇒ Object
32
33
34
35
36
|
# File 'lib/paperlex/slaw.rb', line 32
def html_url(responses = nil, options = {})
params = options.merge(:token => Paperlex.token)
params[:responses] = responses if responses.present?
"#{Paperlex.base_url}/slaws/#{uuid}.html?#{params.to_query}"
end
|
#revert_to_version(version_index) ⇒ Object
56
57
58
|
# File 'lib/paperlex/slaw.rb', line 56
def revert_to_version(version_index)
self.class.new(Paperlex::Slaw::Versions[uuid].revert_to(version_index))
end
|
#to_html(responses = nil, options = {}) ⇒ Object
38
39
40
|
# File 'lib/paperlex/slaw.rb', line 38
def to_html(responses = nil, options = {})
RestClient.get(html_url(responses, options))
end
|
#versions ⇒ Object
47
48
49
|
# File 'lib/paperlex/slaw.rb', line 47
def versions
Paperlex::Slaw::Versions[uuid].all.map {|version| Version.new(version) }
end
|