Class: Camille::Schema

Inherits:
Object
  • Object
show all
Defined in:
lib/camille/schema.rb

Defined Under Namespace

Classes: AlreadyDefinedError

Class Method Summary collapse

Class Method Details

.endpointsObject



5
6
7
# File 'lib/camille/schema.rb', line 5

def self.endpoints
  @endpoints ||= {}
end

.inherited(klass) ⇒ Object



27
28
29
# File 'lib/camille/schema.rb', line 27

def self.inherited klass
  Camille::Loader.loaded_schemas << klass
end

.klass_nameObject



13
14
15
# File 'lib/camille/schema.rb', line 13

def self.klass_name
  self.name.gsub(/^Camille::Schemas::/, '')
end

.literal_linesObject



17
18
19
20
21
22
23
24
25
# File 'lib/camille/schema.rb', line 17

def self.literal_lines
  [
    Camille::Line.new('{'),
    *endpoints.sort_by{|k, e| k}.map do |k, e|
      Camille::Line.new("#{e.function},")
    end.map(&:do_indent),
    Camille::Line.new('}')
  ]
end

.pathObject



9
10
11
# File 'lib/camille/schema.rb', line 9

def self.path
  "/#{ActiveSupport::Inflector.underscore klass_name}"
end