Class: Jax::ResourceFile

Inherits:
Tilt::Template
  • Object
show all
Defined in:
lib/jax/resource_file.rb

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#contextObject (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_typeObject



6
7
8
# File 'lib/jax/resource_file.rb', line 6

def self.default_mime_type
  "application/javascript"
end

Instance Method Details

#class_nameObject



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

#prepareObject



10
11
# File 'lib/jax/resource_file.rb', line 10

def prepare
end

#resource_nameObject



22
23
24
# File 'lib/jax/resource_file.rb', line 22

def resource_name
  File.basename(context.logical_path)
end

#to_jsonObject



26
27
28
# File 'lib/jax/resource_file.rb', line 26

def to_json
  { resource_name => (YAML::load(data) || {}) }.to_json
end