ixtlan-remote 0.1.6 → 0.1.7

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
data/Gemfile CHANGED
@@ -1,5 +1,4 @@
1
1
  source :rubygems
2
2
  gemspec
3
-
4
- # needed for jruby 1.6.8
5
- gem 'jruby-openssl', :platform => :jruby, :group => :test
3
+ # needed for jruby 1.6.8 - inside Mavenfile it does not work
4
+ gem 'jruby-openssl', :platform => :java
@@ -35,14 +35,44 @@ module Ixtlan
35
35
  self
36
36
  end
37
37
 
38
+ ALL_ID = 1
39
+ DEFAULT_ID = 2
40
+
41
+ ALL_NAME= 'ALL'
42
+ DEFAULT_NAME = 'DEFAULT'
43
+
44
+ def self.ALL
45
+ first_or_create( :id => ALL_ID, :name => ALL_NAME )
46
+ end
47
+
48
+ def self.DEFAULT
49
+ first_or_create( :id => DEFAULT_ID, :name => DEFAULT_NAME )
50
+ end
51
+
52
+ def self.almost_all( args = {} )
53
+ all( { :id.gt => ALL_ID }.merge( args ) )
54
+ end
55
+
56
+ def self.first_or_create( args )
57
+ first( args ) || create!( args.merge( {:updated_at => DateTime.new( 1 ) } ) )
58
+ end
59
+
38
60
  property :id, Serial
39
- property :name, String, :unique=>true, :format => /^[a-z]+$/,:required => true, :length => 32
61
+ property :name, String, :unique => true, :format => /ALL|DEFAULT|^[a-z]+$/,:required => true, :length => 32
40
62
 
41
63
  timestamps :updated_at
42
64
 
43
65
  # do not record timestamps since they are set from outside
44
66
  def set_timestamps_on_save
45
67
  end
68
+
69
+ def all?
70
+ name == ALL_NAME
71
+ end
72
+
73
+ def default?
74
+ name == DEFAULT_NAME
75
+ end
46
76
  end
47
77
  end
48
78
  end
metadata CHANGED
@@ -2,14 +2,14 @@
2
2
  name: ixtlan-remote
3
3
  version: !ruby/object:Gem::Version
4
4
  prerelease:
5
- version: 0.1.6
5
+ version: 0.1.7
6
6
  platform: ruby
7
7
  authors:
8
8
  - Christian Meier
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2013-01-28 00:00:00.000000000 Z
12
+ date: 2013-02-09 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: rest-client