Sha256: 887be62a65ec7e608e3dad9de8912bfc3a846feeee1f1065f40404f9333ffc71

Contents?: true

Size: 1.02 KB

Versions: 1

Compression:

Stored size: 1.02 KB

Contents

module Transit
  module Builders
    class PackageBuilder
      
      attr_accessor :form, :resource, :template
      
      def initialize(model, form_builder)
        @form     = form_builder
        @resource = model
        @template = @form.template
      end
      
      def body
        
      end
      
      private
      
      def _create_field_for(method)
        form_method = _lookup_proper_field(method)
        args =[method]        
        if form_method.is_a?(Hash)
          args << form_method[form_method.keys.first]
          form_method = form_method.keys.first
        end        
        form.send(form_method, *args)
      end
      
      def _lookup_proper_field(method)
        resource.admin_options.fields[method]
      end
      
      def method_missing(*args)
        instance_eval <<-METHOD, __FILE__, __LINE__ + 1
          def #{args.first}
            _create_field_for(:#{args.first})
          end
        METHOD
        _create_field_for(args.first.to_sym)
      end
      
    end
       
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
transit-0.0.2 lib/transit/builders/package_builder.rb