OSDN Git Service

refactoring manifest
authoryasushiito <yas@pen-chan.jp>
Sat, 22 Mar 2014 03:53:21 +0000 (12:53 +0900)
committeryasushiito <yas@pen-chan.jp>
Sat, 22 Mar 2014 03:53:21 +0000 (12:53 +0900)
25 files changed:
config/environments/development.rb
lib/manifest.rb
lib/manifest/controller.rb
lib/manifest/controller/action.rb
lib/manifest/controller/action/base.rb
lib/manifest/controller/action/count.rb
lib/manifest/controller/action/list.rb
lib/manifest/manifest.rb
lib/manifest/model.rb
lib/manifest/model/association.rb
lib/manifest/model/attribute.rb
lib/manifest/model/attribute/source/model.rb
lib/manifest/model/peta.rb
lib/manifest/model/peta/base.rb
lib/manifest/model/peta/binder.rb
lib/manifest/model/peta/element.rb
lib/manifest/model/peta/root.rb
lib/manifest_base.rb [new file with mode: 0644]
lib/manifest_base/base.rb [new file with mode: 0644]
lib/manifest_base/factory.rb [new file with mode: 0644]
lib/manifest_base/manifest_base.rb [new file with mode: 0644]
lib/manifest_base/name_values.rb [new file with mode: 0644]
lib/manifest_base/type_args.rb [new file with mode: 0644]
lib/manifest_base/type_name_args.rb [new file with mode: 0644]
lib/manifest_base/values.rb [new file with mode: 0644]

index 650c671..0cbf048 100644 (file)
@@ -3,7 +3,9 @@ Pettanr::Application.configure do
   ActiveSupport::Dependencies.autoload_paths << File::join( Rails.root, 'lib')
   ActiveSupport::Dependencies.explicitly_unloadable_constants << 'Editor' 
   ActiveSupport::Dependencies.explicitly_unloadable_constants << 'Peta' 
+  ActiveSupport::Dependencies.explicitly_unloadable_constants << 'ManifestBase' 
   ActiveSupport::Dependencies.explicitly_unloadable_constants << 'Manifest' 
+  ActiveSupport::Dependencies.explicitly_unloadable_constants << 'LocalManifest' 
   # Settings specified here will take precedence over those in config/application.rb
 
   # In the development environment your application's code is reloaded on
index 1982071..4329151 100644 (file)
@@ -1,5 +1,4 @@
-module Manifest
-end
+require_dependency 'manifest_base/manifest_base'
 require_dependency "manifest/manifest"
 require_dependency "manifest/controller"
 require_dependency "manifest/model"
index 25209e4..ea35a7f 100644 (file)
@@ -1,35 +1,19 @@
-require_dependency "manifest/controller/action"
+ManifestBase.require_modules "manifest/controller/", 
+  %w|action|
+
 module Manifest
-  class Controller
+  class Controller < ManifestBase::Base
     include ControllerModule
-    def self.manager manifest, my_manifests
-      controllers = {}
-      my_manifests.each {|controller_name, controller_manifest|
-        controllers[controller_name] = self.new(manifest, controller_name, controller_manifest)
-      }
-      controllers
-    end
-    
-    attr :manifest, :controller_name, :controller_manifest, :item_name, :actions
-    def initialize manifest, controller_name, controller_manifest
-      @manifest = manifest
-      @controller_name = controller_name
-      @controller_manifest = controller_manifest
-      self.set_default
-      self.init
-    end
+    attr :item_name, :actions
     
     def set_default
-      @controller_manifest['item_name'] ||= ::Manifest.singularize(@controller_name)
-      @controller_manifest['actions'] ||= {}
+      @json['item_name'] ||= ::Manifest.singularize(@name)
+      @json['actions'] ||= {}
     end
     
     def init
-      @item_name = @controller_manifest['item_name']
-      @actions = {}
-      @controller_manifest['actions'].each {|action_name, action_manifest|
-        @actions[action_name] = ActionFactory.factory self, action_name, action_manifest
-      }
+      @item_name = @json['item_name']
+      @actions = ManifestBase.load_type_name_args self, @json, 'actions', ActionFactory, 'list'
     end
     
   end
index 227dac8..ff38680 100644 (file)
@@ -1,24 +1,16 @@
-require_dependency "manifest/controller/action/base"
-require_dependency "manifest/controller/action/list"
-require_dependency "manifest/controller/action/show"
-require_dependency "manifest/controller/action/count"
-require_dependency "manifest/controller/action/new"
-require_dependency "manifest/controller/action/edit"
+ManifestBase.require_modules "manifest/controller/action/", 
+  %w|base list show count new edit|
+
 module Manifest
   module ControllerModule
-    class ActionFactory
+    class ActionFactory < ManifestBase::Factory
       include ActionModule
-      @@types = {
-        'list' => ActionList, 'show' => ActionShow, 'count' => ActionCount, 
-        'new' => ActionNew, 'edit' => ActionEdit
-      }
-      def self.factory controller, action_name, my_manifest
-        my_manifest['type'] ||= 'list'
-        type = my_manifest['type']
-        raise "undefined type for controllers > #{controller.controller_name} > action > #{action_name}\n" unless type
-        my_class = @@types[type]
-        raise "undefined class for controllers > #{controller.controller_name} > action > #{action_name} > #{type}\n" unless my_class
-        my_class.new(controller, action_name, my_manifest)
+      
+      def self.types
+        {
+          'list' => ActionList, 'show' => ActionShow, 'count' => ActionCount, 
+          'new' => ActionNew, 'edit' => ActionEdit
+        }
       end
       
     end
index bec77dd..0f80ff4 100644 (file)
@@ -1,36 +1,20 @@
 module Manifest
   module ControllerModule
     module ActionModule
-      class Base
-        attr :controller, :action_name, :action_manifest, :type, 
-          :item_name
-        def initialize controller, action_name, action_manifest
-          @controller = controller
-          @action_name = action_name
-          @action_manifest = action_manifest
-          self.set_default
-          self.init
-        end
+      class Base < ManifestBase::TypeNameArgs
+        attr :item_name
         
         def set_default
-          @action_manifest['args'] ||= {}
-          @action_manifest['args']['item_name'] ||= self.controller.item_name
+          super
+          @args ||= {}
+          @args['item_name'] ||= self.parent.item_name  # not parent.name. follow singularized name
         end
         
         def init
-          @type = @action_manifest['type']
-          @args = @action_manifest['args']
+          super
           @item_name = @args['item_name']
         end
         
-        def controller_name
-          @controller.controller_name
-        end
-        
-        def controller_manifest
-          @controller.controller_manifest
-        end
-        
       end
       
     end
index 6ce38c7..dd7a0f2 100644 (file)
@@ -6,7 +6,7 @@ module Manifest
         
         def set_default
           super
-          @action_manifest['args']['list_name'] ||= @action_name.gsub(/^count_/, '')
+          @args['list_name'] ||= @name.gsub(/^count_/, '')
         end
         
         def init
index 1efd8c5..4ce8f67 100644 (file)
@@ -6,7 +6,7 @@ module Manifest
         
         def set_default
           super
-          @action_manifest['args']['list_name'] ||= @action_name
+          @args['list_name'] ||= @name
         end
         
         def init
index 17a9680..69ea996 100644 (file)
@@ -2,11 +2,12 @@ module Manifest
   class Manifest
     cattr_accessor :manifest
     attr :system_resources, :magic_numbers,
-      :controllers, :models
+      :controllers, :models, :module_names
     # call me before load routes.rb
     # routes.rb needs engine_resources manifest in system_resources
     # ex. it's adding license_groups routes
     def initialize global_json
+      @module_names = []
       @global_json = global_json || {}
       @system_resources = SystemResource.new(self, SystemResource.set_default(@global_json['system_resources']))
       @magic_numbers = @global_json['magic_numbers']
@@ -15,8 +16,8 @@ module Manifest
     def init
       # managers can't initialize before load  application.rb
       return unless defined? ::Pettanr
-      @controllers = Controller.manager(self, @global_json['controllers'] || {})
-      @models = Model.manager(self, @global_json['models'] || {})
+      @controllers = Controller.load(self, @global_json, 'controllers')
+      @models = Model.load(self, @global_json, 'models')
     end
     
     def system_resources_init
index 3a90899..fdf3064 100644 (file)
@@ -1,69 +1,52 @@
-require_dependency "manifest/model/attribute"
-require_dependency "manifest/model/association"
-require_dependency "manifest/model/list"
-require_dependency "manifest/model/tree"
-require_dependency "manifest/model/peta"
+ManifestBase.require_modules "manifest/model/", 
+  %w|attribute association list tree peta|
 
 module Manifest
-  class Model
+  class Model < ManifestBase::Base
     include ModelModule
-    def self.manager manifest, my_manifests
-      models = {}
-      my_manifests.each {|model_name, model_manifest|
-        models[model_name] = self.new(manifest, model_name, model_manifest)
-      }
-      models
-    end
     
-    attr :model_name, :model_manifest, 
-      :attributes, :associations, :tree, :list, :peta, :extend_column_name
-    def initialize manifest, model_name, model_manifest
-      @manifest = manifest
-      @model_name = model_name
-      @model_manifest = model_manifest
-      self.set_default
-      self.init
-    end
+    attr :attributes, :associations, :tree, :list, :peta, :extend_column_name
     
     def set_default
-      @model_manifest['attributes'] ||= {}
-      @model_manifest['associations'] ||= {}
-      @model_manifest['tree'] ||= {}
-      @model_manifest['list'] ||= {}
-      @model_manifest['extend_column_name'] ||= 'classname'
-      @model_manifest['peta'] ||= {}
-      @model_manifest['attributes']['id'] = {
+      @json['attributes'] ||= {}
+      @json['associations'] ||= {}
+      @json['tree'] ||= {}
+      @json['list'] ||= {}
+      @json['extend_column_name'] ||= 'classname'
+      @json['peta'] ||= {}
+      @json['attributes']['id'] = {
         'type' => 'number',
         'primary_key' => 1,
         'rules' => {
           'number' => true
         }
       }
-      @model_manifest['attributes']['created_at'] = {
+      @json['attributes']['created_at'] = {
         'type' => 'datetime',
       }
-      @model_manifest['attributes']['updated_at'] = {
+      @json['attributes']['updated_at'] = {
         'type' => 'datetime',
       }
     end
     
     def init
-      @attributes = {}
-      @model_manifest['attributes'].each {|attribute_name, attribute_manifest|
-        @attributes[attribute_name] = Attribute.new(self, attribute_name, attribute_manifest)
-      }
-      @associations = Association.new(self, @model_manifest['associations'])
+      @attributes = ManifestBase.load_name_values self, @json, 'attributes', Attribute
+      @associations = ManifestBase.load_value self, @json, 'associations', Association
       @tree = {}
-      @model_manifest['tree'].each {|tree_name, parent_model_name|
+      @json['tree'].each {|tree_name, parent_model_name|
         @tree[tree_name] = Tree.new(self, tree_name, parent_model_name)
       }
-      @peta = PetaFactory.factory(self, @model_manifest['peta'])
-      @extend_column_name = @model_manifest['extend_column_name']
-      @list = List.new(self, @model_manifest['list'])
+      @peta = ManifestBase.load_type_args(self, @json, 'peta', PetaFactory, 'item')
+      @extend_column_name = @json['extend_column_name']
+      @list = List.new(self, @json['list'])
+    end
+    
+    def model_name
+      @name
     end
     
     def classify
-      ::Manifest.item_name_to_model @model_name
+      ::Manifest.item_name_to_model @name
     end
     
     def table_name
index f4886fc..e81624b 100644 (file)
@@ -3,44 +3,36 @@ require_dependency "manifest/model/association/has_many"
 require_dependency "manifest/model/association/has_one"
 module Manifest
   module ModelModule
-    class Association
+    class Association < ManifestBase::Values
       include AssociationModule
-      attr :model, :association_manifest, 
-        :belongs_to, :has_many, :has_one
-      def initialize model, association_manifest
-        @model = model
-        @association_manifest = association_manifest
-        self.set_default
-        self.init
-      end
+      
+      attr :belongs_to, :has_many, :has_one
       
       def set_default
-        @association_manifest['belongs_to'] ||= {}
-        @association_manifest['has_many'] ||= {}
-        @association_manifest['has_one'] ||= {}
+        super
+        @args['belongs_to'] ||= {}
+        @args['has_many'] ||= {}
+        @args['has_one'] ||= {}
       end
       
       def init
+        super
         @belongs_to = {}
         @has_many = {}
         @has_one = {}
-        @association_manifest['belongs_to'].each {|belongs_to_name, belongs_to_manifest|
-          @belongs_to[belongs_to_name] = BelongsTo.new(self, belongs_to_name, belongs_to_manifest)
+        @args['belongs_to'].each {|name, json|
+          @belongs_to[name] = BelongsTo.new(self, name, json)
         }
-        @association_manifest['has_many'].each {|has_many_name, has_many_manifest|
-          @has_many[has_many_name] = HasMany.new(self, has_many_name, has_many_manifest)
+        @args['has_many'].each {|name, json|
+          @has_many[name] = HasMany.new(self, name, json)
         }
-        @association_manifest['has_one'].each {|has_one_name, has_one_manifest|
-          @has_one[has_one_name] = HasOne.new(self, has_one_name, has_one_manifest)
+        @args['has_one'].each {|name, json|
+          @has_one[name] = HasOne.new(self, name, json)
         }
       end
       
       def model_name
-        @model.model_name
-      end
-      
-      def model_manifest
-        @model.model_manifest
+        @parent.name
       end
       
       def child_element_name child_model
index 0d9ab3e..cf8d40a 100644 (file)
@@ -1,41 +1,29 @@
-require_dependency "manifest/model/attribute/source"
+ManifestBase.require_modules "manifest/model/attribute/", 
+  %w|source|
+
 module Manifest
   module ModelModule
-    class Attribute
+    class Attribute < ManifestBase::NameValues
       include AttributeModule
-      attr :model, :attribute_name, :attribute_manifest, 
-        :type, :primary_key, :rules, :source
-      def initialize model, attribute_name, attribute_manifest
-        @model = model
-        @attribute_name = attribute_name
-        @attribute_manifest = attribute_manifest
-        self.set_default
-        self.init
-      end
+      
+      attr :type, :primary_key, :rules, :source
       
       def set_default
-        raise "undefined type for models > #{self.model_name} > attributes > #{@attribute_name}\n" unless @attribute_manifest['type']
-        @attribute_manifest['primary_key'] ||= 0
-        @attribute_manifest['rules'] ||= {}
+        super
+        raise "undefined type for #{self.module_message}\n" unless @args['type']
+        @args['primary_key'] ||= 0
+        @args['rules'] ||= {}
       end
       
       def init
-        @type = @attribute_manifest['type']
-        @primary_key = @attribute_manifest['primary_key']
-        @rules = @attribute_manifest['rules']
-        if @attribute_manifest['source']
-          @source = SourceFactory.factory(self, @attribute_name, @attribute_manifest['source'])
+        super
+        @primary_key = @args['primary_key']
+        @rules = @args['rules']
+        if @args['source']
+          @source = SourceFactory.factory(self, @name, @args['source'])
         end
       end
       
-      def model_name
-        @model.model_name
-      end
-      
-      def model_manifest
-        @model.model_manifest
-      end
-      
     end
     
   end
index d59cf1d..ac7591d 100644 (file)
@@ -15,9 +15,9 @@ module Manifest
           
           def set_default
             @source_manifest['args'] ||= {}
-            @source_manifest['args']['resource_model_name'] ||= (@attribute.attribute_name.gsub('_id', ''))
+            @source_manifest['args']['resource_model_name'] ||= (@attribute.name.gsub('_id', ''))
             @source_manifest['args']['resource_list_name'] ||= 'select_items'
-            @source_manifest['args']['select_item_name'] ||= self.model_name + '_' + self.attribute_name.gsub('_id', '') + '_items'
+            @source_manifest['args']['select_item_name'] ||= self.model_name + '_' + @attribute.name.gsub('_id', '') + '_items'
             @source_manifest['args']['caption_name'] ||= 'caption'
           end
           
@@ -31,11 +31,11 @@ module Manifest
           end
           
           def model_name
-            @attribute.model_name
+            @attribute.parent_name
           end
           
           def attribute_name
-            @attribute.attribute_name
+            @attribute.name
           end
           
         end
index ec46382..9b3dedb 100644 (file)
@@ -1,27 +1,17 @@
-require_dependency "manifest/model/peta/base"
-require_dependency "manifest/model/peta/item"
-require_dependency "manifest/model/peta/owner"
-require_dependency "manifest/model/peta/content"
-require_dependency "manifest/model/peta/root"
-require_dependency "manifest/model/peta/element"
-require_dependency "manifest/model/peta/binder"
-require_dependency "manifest/model/peta/leaf"
+ManifestBase.require_modules "manifest/model/peta/", 
+  %w|base item owner content root element binder leaf|
+
 module Manifest
   module ModelModule
-    class PetaFactory
+    class PetaFactory < ManifestBase::Factory
       include PetaModule
-      @@types = {
-        'item' => ItemPeta, 'owner' => OwnerPeta, 'content' => ContentPeta, 
-        'root' => RootPeta, 'element' => ElementPeta, 
-        'binder' => BinderPeta, 'leaf' => LeafPeta
-      }
-      def self.factory model, my_manifest
-        my_manifest['type'] ||= 'item'
-        type = my_manifest['type']
-        raise "undefined type for models > #{model.model_name} > peta \n" unless type
-        my_class = @@types[type]
-        raise "undefined class for models > #{model.fmodel_name} > peta > #{type}\n" unless my_class
-        my_class.new(model, my_manifest)
+      
+      def self.types
+        {
+          'item' => ItemPeta, 'owner' => OwnerPeta, 'content' => ContentPeta, 
+          'root' => RootPeta, 'element' => ElementPeta, 
+          'binder' => BinderPeta, 'leaf' => LeafPeta
+        }
       end
       
     end
index 64d9381..ce562ee 100644 (file)
@@ -1,23 +1,14 @@
 module Manifest
   module ModelModule
     module PetaModule
-      class BasePeta
-        attr :model, :peta_manifest, :type
-        
-        def initialize model, peta_manifest
-          @model = model
-          @peta_manifest = peta_manifest
-          self.set_default
-          self.init
-        end
+      class BasePeta < ManifestBase::TypeArgs
         
         def set_default
-          @peta_manifest['args'] ||= {}
+          super
         end
         
         def init
-          @type = @peta_manifest['type']
-          @args = @peta_manifest['args']
+          super
         end
         
       end
index 1f85e94..d8bd64c 100644 (file)
@@ -6,7 +6,7 @@ module Manifest
         
         def set_default
           super
-          raise "undefined leaf_tree_name for models> #{@model.model_name} > peta \n" unless @peta_manifest['args']['leaf_tree_name']
+          ManifestBase.undefined_message 'leaf_tree_name',  self.module_message unless @args['leaf_tree_name']
         end
         
         def init
index 434094b..f34b399 100644 (file)
@@ -6,7 +6,7 @@ module Manifest
         
         def set_default
           super
-          raise "undefined element_tree_name for models> #{@model.model_name} > peta \n" unless @peta_manifest['args']['element_tree_name']
+          raise "undefined element_tree_name for #{self.module_message}\n" unless @args['element_tree_name']
         end
         
         def init
index 5adbccd..038295e 100644 (file)
@@ -6,7 +6,7 @@ module Manifest
         
         def set_default
           super
-          raise "undefined element_tree_name for models> #{@model.model_name} > peta \n" unless @peta_manifest['args']['element_tree_name']
+          raise "undefined element_tree_name for #{self.module_message}\n" unless @args['element_tree_name']
         end
         
         def init
diff --git a/lib/manifest_base.rb b/lib/manifest_base.rb
new file mode 100644 (file)
index 0000000..d100de1
--- /dev/null
@@ -0,0 +1,2 @@
+require_dependency "manifest_base/manifest_base"
+r
diff --git a/lib/manifest_base/base.rb b/lib/manifest_base/base.rb
new file mode 100644 (file)
index 0000000..cbbd60e
--- /dev/null
@@ -0,0 +1,76 @@
+module ManifestBase
+  class Base
+    def self.load manifest, jsons, module_name
+      Hash[jsons[module_name].map {|name, json|
+        [name, self.new(manifest, name, json, module_name)]
+      }]
+    end
+    
+    attr :manifest, :name, :name, :module_name
+    
+    def initialize manifest, name, json, module_name
+      @manifest = manifest
+      @name = name
+      @json = json
+      @module_name = module_name
+      self.set_default
+      self.init
+    end
+    
+    def set_default
+    end
+    
+    def init
+    end
+    
+    def module_names
+      @manifest.module_names + [@module_name, @name]
+    end
+    
+  end
+  
+  module ModuleMethods
+    def require_modules path, names
+      names.each do |name|
+        require_dependency path + name.to_s
+      end
+    end
+    
+    def module_message module_names, my_module_names = []
+      (module_names + my_module_names).join(' > ')
+    end
+    
+    def alert_message message, location
+      raise "#{message} for #{message}\n"
+    end
+    
+    def undefined_message name, location
+      alert_message 'undefined ' + name, location
+    end
+    
+    def load_value _self, json, module_name, klass
+      klass.new(_self, json[module_name], module_name)
+    end
+    
+    def load_name_values _self, jsons, module_name, klass
+      Hash[jsons[module_name].map {|_name, _json|
+        [_name, klass.new(_self, _name, _json, module_name)]
+      }]
+    end
+    
+    def load_type_args _self, jsons, module_name, klass, default_type = nil
+      klass.factory_type_args(_self, jsons[module_name], module_name, default_type)
+    end
+    
+    def load_type_name_args _self, jsons, module_name, klass, default_type = nil
+      Hash[jsons[module_name].map {|_name, _json|
+        [_name, klass.factory(_self, _name, _json, module_name, default_type)]
+      }]
+    end
+    
+  end
+
+  extend ModuleMethods
+
+end
+
diff --git a/lib/manifest_base/factory.rb b/lib/manifest_base/factory.rb
new file mode 100644 (file)
index 0000000..f7e8cbe
--- /dev/null
@@ -0,0 +1,29 @@
+module ManifestBase
+  class Factory
+    def self.types
+      {}
+    end
+    
+    def self.factory parent, name, json, module_name, default_type = nil
+      module_message = ManifestBase.module_message(parent.module_names, [module_name, name])
+      json['type'] ||= default_type
+      type = json['type']
+      raise "undefined type for #{module_message}\n" unless type
+      my_class = self.types[type]
+      raise "undefined class for #{module_message} > #{type}\n" unless my_class
+      my_class.new(parent, name, json, module_name)
+    end
+    
+    def self.factory_type_args parent, json, module_name, default_type = nil
+      module_message = ManifestBase.module_message(parent.module_names, [module_name])
+      json['type'] ||= default_type
+      type = json['type']
+      raise "undefined type for #{module_message}\n" unless type
+      my_class = self.types[type]
+      raise "undefined class for #{module_message} > #{type}\n" unless my_class
+      my_class.new(parent, json, module_name)
+    end
+    
+  end
+end
+
diff --git a/lib/manifest_base/manifest_base.rb b/lib/manifest_base/manifest_base.rb
new file mode 100644 (file)
index 0000000..1478565
--- /dev/null
@@ -0,0 +1,2 @@
+require_dependency "manifest_base/base"
+require_dependency "manifest_base/factory"
diff --git a/lib/manifest_base/name_values.rb b/lib/manifest_base/name_values.rb
new file mode 100644 (file)
index 0000000..ae3531c
--- /dev/null
@@ -0,0 +1,39 @@
+module ManifestBase
+  class NameValues
+    attr :parent, :name, :json, :module_name
+    
+    def initialize parent, name, json, module_name
+      @parent = parent
+      @name = name
+      @json = json
+      @module_name = module_name
+      self.set_default
+      self.init
+    end
+    
+    def set_default
+      @args = @json
+    end
+    
+    def init
+    end
+    
+    def module_names
+      self.parent.module_names + [@module_name, @name]
+    end
+    
+    def module_message
+      ManifestBase.module_message(self.module_names)
+    end
+    
+    def parent_name
+      @parent.name
+    end
+    
+    def parent_json
+      @parent.json
+    end
+    
+  end
+end
+
diff --git a/lib/manifest_base/type_args.rb b/lib/manifest_base/type_args.rb
new file mode 100644 (file)
index 0000000..e64e35b
--- /dev/null
@@ -0,0 +1,39 @@
+module ManifestBase
+  class TypeArgs
+    attr :parent, :json, :type, :module_name
+    
+    def initialize parent, json, module_name
+      @parent = parent
+      @json = json
+      @module_name = module_name
+      self.set_default
+      self.init
+    end
+    
+    def set_default
+      @type = @json['type']
+      @args = @json['args']
+    end
+    
+    def init
+    end
+    
+    def module_names
+      self.parent.module_names + [@module_name]
+    end
+    
+    def module_message
+      ManifestBase.module_message(self.module_names)
+    end
+    
+    def parent_name
+      @parent.name
+    end
+    
+    def parent_json
+      @parent.json
+    end
+    
+  end
+end
+
diff --git a/lib/manifest_base/type_name_args.rb b/lib/manifest_base/type_name_args.rb
new file mode 100644 (file)
index 0000000..688bbe6
--- /dev/null
@@ -0,0 +1,41 @@
+module ManifestBase
+  class TypeNameArgs
+    attr :parent, :name, :json, :type, :module_name
+    
+    def initialize parent, name, json, module_name
+      @parent = parent
+      @name = name
+      @json = json
+      @module_name = module_name
+      self.set_default
+      self.init
+    end
+    
+    def set_default
+      @json['args'] ||= {}
+      @type = @json['type']
+      @args = @json['args']
+    end
+    
+    def init
+    end
+    
+    def module_names
+      self.parent.module_names + [@module_name, @name]
+    end
+    
+    def module_message
+      ManifestBase.module_message(self.module_names)
+    end
+    
+    def parent_name
+      @parent.name
+    end
+    
+    def parent_json
+      @parent.json
+    end
+    
+  end
+end
+
diff --git a/lib/manifest_base/values.rb b/lib/manifest_base/values.rb
new file mode 100644 (file)
index 0000000..fe87a66
--- /dev/null
@@ -0,0 +1,38 @@
+module ManifestBase
+  class Values
+    attr :parent, :json, :module_name
+    
+    def initialize parent, json, module_name
+      @parent = parent
+      @json = json
+      @module_name = module_name
+      self.set_default
+      self.init
+    end
+    
+    def set_default
+      @args = @json
+    end
+    
+    def init
+    end
+    
+    def module_names
+      self.parent.module_names + [@module_name]
+    end
+    
+    def module_message
+      ManifestBase.module_message(self.module_names)
+    end
+    
+    def parent_name
+      @parent.name
+    end
+    
+    def parent_json
+      @parent.json
+    end
+    
+  end
+end
+