Class: ActiveFacts::Generators::Metadata::JSON
- Inherits:
-
Object
- Object
- ActiveFacts::Generators::Metadata::JSON
- Defined in:
- lib/activefacts/generators/metadata/json.rb
Overview
:nodoc:
Instance Method Summary collapse
- #generate(out = $>) ⇒ Object
-
#initialize(vocabulary, *options) ⇒ JSON
constructor
A new instance of JSON.
-
#object_types_dump ⇒ Object
Store the metadata for all types into the types section of the @metadata hash.
- #set_option(option) ⇒ Object
Constructor Details
#initialize(vocabulary, *options) ⇒ JSON
Returns a new instance of JSON.
17 18 19 20 21 |
# File 'lib/activefacts/generators/metadata/json.rb', line 17 def initialize(vocabulary, *) @vocabulary = vocabulary @vocabulary = @vocabulary.Vocabulary.values[0] if ActiveFacts::API::Constellation === @vocabulary .each{|option| set_option(option) } end |
Instance Method Details
#generate(out = $>) ⇒ Object
26 27 28 29 30 31 32 |
# File 'lib/activefacts/generators/metadata/json.rb', line 26 def generate(out = $>) @metadata = {"types" => {}} object_types_dump out.puts ::JSON.pretty_generate(@metadata) end |
#object_types_dump ⇒ Object
Store the metadata for all types into the types section of the @metadata hash
35 36 37 38 39 40 41 42 43 44 45 46 47 |
# File 'lib/activefacts/generators/metadata/json.rb', line 35 def object_types_dump types = @metadata["types"] # Compute the relational mapping if not already done: @tables ||= @vocabulary.tables @vocabulary.all_object_type. sort_by{|c| c.name}.each do |o| object_type = o. types[o.name] = object_type if object_type end end |
#set_option(option) ⇒ Object
23 24 |
# File 'lib/activefacts/generators/metadata/json.rb', line 23 def set_option(option) end |