Class: REDCap
- Inherits:
-
Object
- Object
- REDCap
- Defined in:
- lib/red_cap.rb,
lib/red_cap/form.rb,
lib/red_cap/cache.rb,
lib/red_cap/client.rb,
lib/red_cap/version.rb,
lib/red_cap/form/fields.rb
Defined Under Namespace
Constant Summary collapse
- VERSION =
"0.12.1"
Class Attribute Summary collapse
-
.cache ⇒ Object
Returns the value of attribute cache.
-
.per_page ⇒ Object
Returns the value of attribute per_page.
-
.token ⇒ Object
Returns the value of attribute token.
-
.url ⇒ Object
Returns the value of attribute url.
Instance Attribute Summary collapse
-
#per_page ⇒ Object
Returns the value of attribute per_page.
-
#token ⇒ Object
Returns the value of attribute token.
-
#url ⇒ Object
Returns the value of attribute url.
Class Method Summary collapse
Instance Method Summary collapse
- #all(&block) ⇒ Object
- #client ⇒ Object
- #delete(study_id) ⇒ Object
- #find(study_id) ⇒ Object
- #form ⇒ Object
-
#initialize(url: REDCap.url, token: REDCap.token, per_page: REDCap.per_page) ⇒ REDCap
constructor
A new instance of REDCap.
- #update(study_id, attributes) ⇒ Object
- #where(conditions, &block) ⇒ Object
Constructor Details
Class Attribute Details
.cache ⇒ Object
Returns the value of attribute cache.
11 12 13 |
# File 'lib/red_cap.rb', line 11 def cache @cache end |
.per_page ⇒ Object
Returns the value of attribute per_page.
11 12 13 |
# File 'lib/red_cap.rb', line 11 def per_page @per_page end |
.token ⇒ Object
Returns the value of attribute token.
11 12 13 |
# File 'lib/red_cap.rb', line 11 def token @token end |
.url ⇒ Object
Returns the value of attribute url.
11 12 13 |
# File 'lib/red_cap.rb', line 11 def url @url end |
Instance Attribute Details
#per_page ⇒ Object
Returns the value of attribute per_page.
24 25 26 |
# File 'lib/red_cap.rb', line 24 def per_page @per_page end |
#token ⇒ Object
Returns the value of attribute token.
24 25 26 |
# File 'lib/red_cap.rb', line 24 def token @token end |
#url ⇒ Object
Returns the value of attribute url.
24 25 26 |
# File 'lib/red_cap.rb', line 24 def url @url end |
Class Method Details
.configure {|_self| ... } ⇒ Object
7 8 9 |
# File 'lib/red_cap.rb', line 7 def configure yield self end |
Instance Method Details
#all(&block) ⇒ Object
34 35 36 |
# File 'lib/red_cap.rb', line 34 def all &block client.records &block end |
#client ⇒ Object
54 55 56 |
# File 'lib/red_cap.rb', line 54 def client @client ||= Client.new(url: url, token: token, per_page: per_page) end |
#delete(study_id) ⇒ Object
50 51 52 |
# File 'lib/red_cap.rb', line 50 def delete study_id client.delete_records [study_id] end |
#find(study_id) ⇒ Object
30 31 32 |
# File 'lib/red_cap.rb', line 30 def find study_id client.find_record study_id end |
#update(study_id, attributes) ⇒ Object
45 46 47 48 |
# File 'lib/red_cap.rb', line 45 def update study_id, attributes record = attributes.merge(study_id: study_id).stringify_keys client.save_records [record] end |
#where(conditions, &block) ⇒ Object
38 39 40 41 42 43 |
# File 'lib/red_cap.rb', line 38 def where conditions, &block filters = conditions.reduce([]) do |filters, (field, value)| filters << "[#{field}]=#{value}" end client.records(filters.join(" AND "), &block) end |