Module: DmSvn::Svn::ClassMethods
- Defined in:
- lib/dm-svn/svn.rb,
lib/dm-svn/svn/categorized.rb
Instance Method Summary collapse
-
#belongs_to(what, options = {}) ⇒ Object
Override belongs_to to add a :dm-svn option if :dm-svn => true, include Categorized and set up @svn_category and @svn_category_model instance methods.
- #config ⇒ Object
-
#get(path_or_id, *args) ⇒ Object
Override normal get behavior to try to get based on path if the argument is a String.
- #get_by_path(path) ⇒ Object
-
#get_or_create(path) ⇒ Object
Try to get by path.
-
#property(name, type, options = {}) ⇒ Object
Override DataMapper’s
property
class method to accept as an optionbody_property
. -
#svn_category ⇒ Object
Method name for accessing the parent instance.
-
#svn_category_model ⇒ Object
Name of the parent model class (as a String).
-
#svn_repository ⇒ Object
DataMapper uses
repository
, so prepend “svn_”. - #sync ⇒ Object
Instance Method Details
#belongs_to(what, options = {}) ⇒ Object
Override belongs_to to add a :dm-svn option if :dm-svn => true, include Categorized and set up @svn_category and @svn_category_model instance methods.
9 10 11 12 13 14 15 16 17 18 |
# File 'lib/dm-svn/svn/categorized.rb', line 9 def belongs_to(what, = {}) svn = .delete(:svn) if svn @svn_category = what @svn_category_model = [:model] || [:class_name] || what.to_s.camel_case include(DmSvn::Svn::Categorized) end super end |
#get(path_or_id, *args) ⇒ Object
Override normal get behavior to try to get based on path if the argument is a String. Extra args are ignored by default.
115 116 117 118 119 120 121 |
# File 'lib/dm-svn/svn.rb', line 115 def get(path_or_id, *args) if path_or_id.is_a?(String) get_by_path(path_or_id) else super end end |
#get_by_path(path) ⇒ Object
134 135 136 |
# File 'lib/dm-svn/svn.rb', line 134 def get_by_path(path) first(:svn_name => path) end |
#get_or_create(path) ⇒ Object
Try to get by path. If not, create a new record and so set its path.
124 125 126 127 128 129 130 131 132 |
# File 'lib/dm-svn/svn.rb', line 124 def get_or_create(path) i = get_by_path(path) return i if i i = create i.path = path i.save return i end |
#property(name, type, options = {}) ⇒ Object
Override DataMapper’s property
class method to accept as an option body_property
. Setting this option tells DmSvn::Svn that this field will store the contents of the repository file.
91 92 93 94 95 96 97 |
# File 'lib/dm-svn/svn.rb', line 91 def property(name, type, = {}) if .delete(:body_property) config.body_property = name.to_s end super(name, type, ) end |
#svn_category ⇒ Object
Method name for accessing the parent instance.
21 22 23 |
# File 'lib/dm-svn/svn/categorized.rb', line 21 def svn_category @svn_category end |
#svn_category_model ⇒ Object
Name of the parent model class (as a String)
26 27 28 |
# File 'lib/dm-svn/svn/categorized.rb', line 26 def svn_category_model @svn_category_model end |
#svn_repository ⇒ Object
DataMapper uses repository
, so prepend “svn_”
100 101 102 103 104 105 106 107 |
# File 'lib/dm-svn/svn.rb', line 100 def svn_repository return @svn_repository if @svn_repository @svn_repository = DmSvn::Model.first(:name => self.name) @svn_repository ||= DmSvn::Model.create(:name => self.name, :revision => 0) @svn_repository.config = config @svn_repository end |