Class: Wikidotrb::Module::SitePageMethods
- Inherits:
-
Object
- Object
- Wikidotrb::Module::SitePageMethods
- Defined in:
- lib/wikidotrb/module/site.rb
Instance Method Summary collapse
-
#create(fullname:, title: "", source: "", comment: "", force_edit: false) ⇒ Page
Create a page.
-
#get(fullname, raise_when_not_found: true) ⇒ Page?
Get a page by its fullname.
-
#initialize(site) ⇒ SitePageMethods
constructor
A new instance of SitePageMethods.
Constructor Details
#initialize(site) ⇒ SitePageMethods
Returns a new instance of SitePageMethods.
27 28 29 |
# File 'lib/wikidotrb/module/site.rb', line 27 def initialize(site) @site = site end |
Instance Method Details
#create(fullname:, title: "", source: "", comment: "", force_edit: false) ⇒ Page
Create a page
54 55 56 57 58 59 60 61 62 63 64 |
# File 'lib/wikidotrb/module/site.rb', line 54 def create(fullname:, title: "", source: "", comment: "", force_edit: false) Page.create_or_edit( site: @site, fullname: fullname, title: title, source: source, comment: comment, force_edit: force_edit, raise_on_exists: true ) end |
#get(fullname, raise_when_not_found: true) ⇒ Page?
Get a page by its fullname
35 36 37 38 39 40 41 42 43 44 45 |
# File 'lib/wikidotrb/module/site.rb', line 35 def get(fullname, raise_when_not_found: true) res = PageCollection.search_pages(@site, Wikidotrb::Module::SearchPagesQuery.new(fullname: fullname)) if res.empty? raise Wikidotrb::Common::Exceptions::NotFoundException, "Page is not found: #{fullname}" if raise_when_not_found return nil end res.first end |