Class: KManager::Resources::RubyFileResource
- Inherits:
-
FileResource
- Object
- BaseResource
- FileResource
- KManager::Resources::RubyFileResource
- Defined in:
- lib/k_manager/resources/file_resources/ruby_file_resource.rb
Overview
Represents a Ruby file resource.
Constant Summary
Constants inherited from FileResource
FileResource::KNOWN_EXTENSIONS
Constants inherited from BaseResource
Instance Attribute Summary
Attributes inherited from BaseResource
#area, #content, #content_type, #documents, #namespace, #status, #uri
Instance Method Summary collapse
-
#initialize(**opts) ⇒ RubyFileResource
constructor
A new instance of RubyFileResource.
- #register_document ⇒ Object
Methods inherited from FileResource
#attribute_values, #debug, #default_scheme, #infer_key, #recreate, #resource_path, #resource_relative_path, #resource_valid?, #source_path
Methods inherited from BaseResource
#activated?, #alive?, #attach_document, #attribute_values, #content_loaded?, #debug, #default_content_type, #default_scheme, #documents_loaded?, #documents_preloaded?, #documents_registered?, #fire_action, #fire_next_action, #host, #infer_content_type, #infer_key, #load_content, #load_document, #new_document, #preload_document, #scheme, #source_path, valid_action?
Constructor Details
#initialize(**opts) ⇒ RubyFileResource
Returns a new instance of RubyFileResource.
7 8 9 10 |
# File 'lib/k_manager/resources/file_resources/ruby_file_resource.rb', line 7 def initialize(**opts) super(**opts) @type = :ruby end |
Instance Method Details
#register_document ⇒ Object
12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 |
# File 'lib/k_manager/resources/file_resources/ruby_file_resource.rb', line 12 def register_document KManager.target_resource = self Object.class_eval content # rescue StandardError => exception # # Report the error but still add the document so that you can see # # it in the ResourceDocument list, it will be marked as Error # resource.error = exception # L.exception resource.error ensure KManager.target_resource = nil # A regular ruby file would not add resource_documents # so create one manually @document = super if documents.length.zero? end |