lib/rasn1/model.rb in rasn1-0.6.7 vs lib/rasn1/model.rb in rasn1-0.6.8

- old
+ new

@@ -58,10 +58,12 @@ # this method. # @author Sylvain Daubert class Model class << self + # @return [Hash] + attr_reader :options # Use another model in this model # @param [String,Symbol] name # @param [Class] model_klass def model(name, model_klass) @@ -88,11 +90,11 @@ # On inheritance, create +@root+ class variable # @param [Class] klass # @return [void] def inherited(klass) super - root = @root + root = defined?(@root )? @root : nil klass.class_eval { @root = root } end # @method sequence(name, options) # @param [Symbol,String] name name of object in model @@ -216,11 +218,11 @@ end # Give type name (aka class name) # @return [String] def type - return @type if @type + return @type if defined? @type @type = self.to_s.gsub(/.*::/, '') end # Parse a DER/BER encoded string # @param [String] str @@ -345,10 +347,10 @@ def generate_root root = self.class.class_eval { @root } @root = root[0] @elements = {} - @elements[@root] = get_type(root[1], self.class.class_eval { @options } || {}) + @elements[@root] = get_type(root[1], self.class.options || {}) root end def set_elements(name, el, content=nil) if content.is_a? Array