Changeset 110


Ignore:
Timestamp:
Oct 14, 2008, 1:02:57 AM (10 years ago)
Author:
KOBAYASHI, Shinji
Message:

refs #63, #64

Location:
ruby/trunk/lib/models
Files:
1 added
3 edited

Legend:

Unmodified
Added
Removed
  • ruby/trunk/lib/models/rm.rb

    r104 r110  
    1717      autoload :Archetyped, "rm/common/archetyped.rb"
    1818      autoload :Generic, "rm/common/generic.rb"
     19      autoload :Directory, "rm/common/directory.rb"
    1920    end
    2021
  • ruby/trunk/lib/models/rm/common/archetyped.rb

    r104 r110  
    3838        class Locatable < Pathable
    3939          include Locater_Constants
    40           attr_accessor :uid, :archetype_node_id, :archetype_details
    41           attr_accessor :feeder_audit, :links, :parent
    42           def initialize(uid, archetype_node_id, name, archetype_details,
    43                          feeder_audit, links, parent)
     40          attr_reader :archetype_node_id, :name, :links
     41          attr_accessor :uid, :archetype_details, :feeder_audit
     42          def initialize(archetype_node_id, name, links, parent=nil, uid=nil, archetype_details=nil, feeder_audit=nil)
    4443            super(parent)
    45             if archetype_node_id.nil?
    46               raise ArgumentError, "null archetype_node_id"
    47             end
    48             if name.nil?
    49               raise ArgumentError, "name is empty"
    50             end
    51             if links.nil?
    52               raise ArgumentError, "links is empty"
    53             end
    54             @uid = uid
     44            self.archetype_node_id = archetype_node_id
     45            self.name = name
     46            self.links = links
     47            self.uid = uid
     48            self.archetype_details = archetype_details
     49            self.feeder_audit = feeder_audit
     50            self.parent = parent
     51          end
     52         
     53          def archetype_node_id=(archetype_node_id)
     54            raise ArgumentError, 'archetype_node_id should not be nil' if archetype_node_id.nil?
    5555            @archetype_node_id = archetype_node_id
    56             @archetype_details = archetype_details
    57             @feeder_audit = feeder_audit
     56          end
     57
     58          def name=(name)
     59            raise ArgumentError, 'name should not be empty' if name.nil? or name.empty?
     60            @name = name
     61          end
     62          def links=(links)
     63            raise ArgumentError, "links shoud not be nil" if links.nil?
    5864            @links = links
    59             @parent = parent
    6065          end
    6166          def item_at_path(path)
     
    8893            self.archetype_id = archetype_id
    8994            self.rm_version = rm_version
    90             @template_id = template_id
     95            self.template_id = template_id
    9196          end
    9297          def archetype_id=(archetype_id)
     
    119124            @type = type
    120125          end
    121         end
    122       end # end of Archetyped
    123     end # end of Common
    124   end # end of RM
    125 end # end of OpenEHR
     126        end # of Link
     127      end # of Archetyped
     128    end # of Common
     129  end # of RM
     130end # OpenEHR
  • ruby/trunk/lib/models/tests/test_reference_model.rb

    r108 r110  
    509509  end
    510510end
     511
     512class RM_Common_Directory_Test < Test::Unit::TestCase
     513  def setup
     514    dv_text = OpenEHR::RM::Data_Types::Text::DV_Text.new('root')
     515    assert_nothing_raised(Exception){@folder = OpenEHR::RM::Common::Directory::Folder.new('at0000', dv_text)}
     516  end
     517 
     518  def test_init
     519    assert_instance_of OpenEHR::RM::Common::Directory::Folder, @folder
     520  end
     521
     522  def test_folder
     523    assert_equal 'root', @folder.archetype_node_id
     524    assert_equal 'name', @folder.name.value
     525  end
     526end 
Note: See TracChangeset for help on using the changeset viewer.