Class: CanvasApi::Render
- Inherits:
-
Object
- Object
- CanvasApi::Render
- Includes:
- GraphQLHelpers, JsHelpers, RubyHelpers
- Defined in:
- lib/canvas_api/render.rb
Instance Attribute Summary collapse
-
#api ⇒ Object
Returns the value of attribute api.
-
#api_url ⇒ Object
Returns the value of attribute api_url.
-
#args(api_url) ⇒ Object
Returns the value of attribute args.
-
#content ⇒ Object
Returns the value of attribute content.
-
#description ⇒ Object
Returns the value of attribute description.
-
#method ⇒ Object
Returns the value of attribute method.
-
#model ⇒ Object
Returns the value of attribute model.
-
#model_name ⇒ Object
Returns the value of attribute model_name.
-
#name ⇒ Object
Returns the value of attribute name.
-
#nickname ⇒ Object
Returns the value of attribute nickname.
-
#notes ⇒ Object
Returns the value of attribute notes.
-
#operation ⇒ Object
Returns the value of attribute operation.
-
#resource ⇒ Object
Returns the value of attribute resource.
-
#resource_api ⇒ Object
Returns the value of attribute resource_api.
-
#resource_name ⇒ Object
Returns the value of attribute resource_name.
-
#summary ⇒ Object
Returns the value of attribute summary.
-
#template ⇒ Object
Returns the value of attribute template.
Instance Method Summary collapse
-
#initialize(template, api, resource, resource_api, operation, parameters, content, model) ⇒ Render
constructor
A new instance of Render.
- #render ⇒ Object
- #save(file) ⇒ Object
Methods included from RubyHelpers
Methods included from JsHelpers
#js_args, #js_url_parts, #key_args, #parameters_doc, #reducer_key
Methods included from GraphQLHelpers
#canvas_name, #enum_class_name, #graphql_field_enums, #graphql_fields, #graphql_primitive, #graphql_resolve, #graphql_type, #is_basic_type, #make_file_name, #name_from_operation, #nested_arg, #no_brackets, #params_as_string, #require_from_operation, #require_from_properties, #safe_js, #safe_rb, #type_from_operation
Constructor Details
#initialize(template, api, resource, resource_api, operation, parameters, content, model) ⇒ Render
Returns a new instance of Render.
16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 |
# File 'lib/canvas_api/render.rb', line 16 def initialize(template, api, resource, resource_api, operation, parameters, content, model) @template = File.read(File.(template, __dir__)) if api @api = api @name = @api["path"].gsub("/", "").gsub(".json", "") @description = @api["description"] end if resource @resource = resource @resource_name = resource["resourcePath"].gsub("/", "") end if resource_api @resource_api = resource_api @api_url = resource_api["path"].gsub("/v1/", "") @args = args(@api_url) end if operation nickname = operation["nickname"] nickname = "#{@name}_#{nickname}" if [ "upload_file", "query_by_course", "preview_processed_html", "create_peer_review_courses", "create_peer_review_sections", "set_extensions_for_student_quiz_submissions" ].include?(nickname) @method = operation["method"] @operation = operation @nickname = nickname @notes = operation["notes"].gsub("\n", "\n// ") @summary = operation["summary"] end if parameters @parameters = parameters.map { |p| p.delete("description"); p } end @content = content @model = model end |
Instance Attribute Details
#api ⇒ Object
Returns the value of attribute api.
12 13 14 |
# File 'lib/canvas_api/render.rb', line 12 def api @api end |
#api_url ⇒ Object
Returns the value of attribute api_url.
12 13 14 |
# File 'lib/canvas_api/render.rb', line 12 def api_url @api_url end |
#args(api_url) ⇒ Object
Returns the value of attribute args.
12 13 14 |
# File 'lib/canvas_api/render.rb', line 12 def args @args end |
#content ⇒ Object
Returns the value of attribute content.
12 13 14 |
# File 'lib/canvas_api/render.rb', line 12 def content @content end |
#description ⇒ Object
Returns the value of attribute description.
12 13 14 |
# File 'lib/canvas_api/render.rb', line 12 def description @description end |
#method ⇒ Object
Returns the value of attribute method.
12 13 14 |
# File 'lib/canvas_api/render.rb', line 12 def method @method end |
#model ⇒ Object
Returns the value of attribute model.
12 13 14 |
# File 'lib/canvas_api/render.rb', line 12 def model @model end |
#model_name ⇒ Object
Returns the value of attribute model_name.
12 13 14 |
# File 'lib/canvas_api/render.rb', line 12 def model_name @model_name end |
#name ⇒ Object
Returns the value of attribute name.
12 13 14 |
# File 'lib/canvas_api/render.rb', line 12 def name @name end |
#nickname ⇒ Object
Returns the value of attribute nickname.
12 13 14 |
# File 'lib/canvas_api/render.rb', line 12 def nickname @nickname end |
#notes ⇒ Object
Returns the value of attribute notes.
12 13 14 |
# File 'lib/canvas_api/render.rb', line 12 def notes @notes end |
#operation ⇒ Object
Returns the value of attribute operation.
12 13 14 |
# File 'lib/canvas_api/render.rb', line 12 def operation @operation end |
#resource ⇒ Object
Returns the value of attribute resource.
12 13 14 |
# File 'lib/canvas_api/render.rb', line 12 def resource @resource end |
#resource_api ⇒ Object
Returns the value of attribute resource_api.
12 13 14 |
# File 'lib/canvas_api/render.rb', line 12 def resource_api @resource_api end |
#resource_name ⇒ Object
Returns the value of attribute resource_name.
12 13 14 |
# File 'lib/canvas_api/render.rb', line 12 def resource_name @resource_name end |
#summary ⇒ Object
Returns the value of attribute summary.
12 13 14 |
# File 'lib/canvas_api/render.rb', line 12 def summary @summary end |
#template ⇒ Object
Returns the value of attribute template.
12 13 14 |
# File 'lib/canvas_api/render.rb', line 12 def template @template end |
Instance Method Details
#render ⇒ Object
64 65 66 |
# File 'lib/canvas_api/render.rb', line 64 def render ERB.new(@template, nil, "-").result(binding).strip end |
#save(file) ⇒ Object
68 69 70 |
# File 'lib/canvas_api/render.rb', line 68 def save(file) File.write(file, render) end |