MongoidOslc
Extension for mongoid to parse oslc.where
Installation
Add this line to your application's Gemfile:
gem 'mongoid_oslc'
And then execute:
$ bundle
Or install it yourself as:
$ gem install mongoid_oslc
Usage
Configure
Add initializer with your configuration.
Mongoid::Oslc.configure do |config|
config.default_namespaces = [:oslc_custom]
end
Include Mongoid::Oslc module to your document
class Article
include Mongoid::Document
include Mongoid::Oslc
domain 'oslc_cm'
describe 'http://open-services.net/ns/cm#ChangeRequest'
oslc_field :title, type: String, mapping: 'dcterms:title'
oslc_field :description, type: String, mapping: 'dcterms:description'
end
Search
Article.oslc_where('dcterms:title="First article" and dcterms:description="First article description"')
=> #<Mongoid::Criteria
selector: {"title"=>"First article", "description"=>"First article description"},
options: {},
class: Article,
embedded: false>
Mappings
Mongoid::Oslc.resources.mapping
=> {
"dcterms:title"=>{
:name=>:title,
:value_type=>"http://www.w3.org/2001/XMLSchema#string",
:read_only=>false,
:occurs=>"http://open-services.net/ns/core#Zero-or-one",
:allowed_values=>[],
:embedded=>false,
:range=>[]
},
"dcterms:description"=>{
:name=>:description,
:value_type=>"http://www.w3.org/2001/XMLSchema#string",
:read_only=>false,
:occurs=>"http://open-services.net/ns/core#Zero-or-one",
:allowed_values=>[],
:embedded=>false,
:range=>[]
}
}
Contributing
- Fork it
- Create your feature branch (
git checkout -b my-new-feature) - Commit your changes (
git commit -am 'Add some feature') - Push to the branch (
git push origin my-new-feature) - Create new Pull Request


