Class: Jax::ResourceFile
- Inherits:
-
Tilt::Template
- Object
- Tilt::Template
- Jax::ResourceFile
- Defined in:
- lib/jax/resource_file.rb
Instance Attribute Summary collapse
-
#context ⇒ Object
readonly
Returns the value of attribute context.
Class Method Summary collapse
Instance Method Summary collapse
- #class_name ⇒ Object
- #evaluate(scope, locals, &block) ⇒ Object
- #prepare ⇒ Object
- #resource_name ⇒ Object
- #to_json ⇒ Object
Instance Attribute Details
#context ⇒ Object (readonly)
Returns the value of attribute context.
4 5 6 |
# File 'lib/jax/resource_file.rb', line 4 def context @context end |
Class Method Details
.default_mime_type ⇒ Object
6 7 8 |
# File 'lib/jax/resource_file.rb', line 6 def self.default_mime_type "application/javascript" end |
Instance Method Details
#class_name ⇒ Object
18 19 20 |
# File 'lib/jax/resource_file.rb', line 18 def class_name File.basename(File.dirname(context.logical_path)).camelize.singularize end |
#evaluate(scope, locals, &block) ⇒ Object
13 14 15 16 |
# File 'lib/jax/resource_file.rb', line 13 def evaluate(scope, locals, &block) @context = scope "#{class_name}.addResources(#{to_json});" end |
#prepare ⇒ Object
10 11 |
# File 'lib/jax/resource_file.rb', line 10 def prepare end |
#resource_name ⇒ Object
22 23 24 |
# File 'lib/jax/resource_file.rb', line 22 def resource_name File.basename(context.logical_path) end |
#to_json ⇒ Object
26 27 28 |
# File 'lib/jax/resource_file.rb', line 26 def to_json { resource_name => (YAML::load(data) || {}) }.to_json end |