validatable_form 0.0.1 → 0.0.2
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/VERSION +1 -1
 - data/lib/validatable_form.rb +1 -1
 - data/spec/validatable_form_spec.rb +6 -0
 - metadata +23 -12
 
    
        data/VERSION
    CHANGED
    
    | 
         @@ -1 +1 @@ 
     | 
|
| 
       1 
     | 
    
         
            -
            0.0. 
     | 
| 
      
 1 
     | 
    
         
            +
            0.0.2
         
     | 
    
        data/lib/validatable_form.rb
    CHANGED
    
    | 
         @@ -7,7 +7,7 @@ class ValidatableForm 
     | 
|
| 
       7 
7 
     | 
    
         
             
                return if form_fields.empty?
         
     | 
| 
       8 
8 
     | 
    
         
             
                attr_accessor *form_fields # !> `*' interpreted as argument prefix
         
     | 
| 
       9 
9 
     | 
    
         
             
                initializations = form_fields.map { |field| "@#{field} = params[:#{field}]"}.join("\n")
         
     | 
| 
       10 
     | 
    
         
            -
                module_eval "def initialize(params={})\n #{initializations}\n end"
         
     | 
| 
      
 10 
     | 
    
         
            +
                module_eval "def initialize(params={})\n return unless params\n #{initializations}\n end"
         
     | 
| 
       11 
11 
     | 
    
         
             
              end
         
     | 
| 
       12 
12 
     | 
    
         | 
| 
       13 
13 
     | 
    
         
             
              # used by some of the Rails view helpers like form_for
         
     | 
| 
         @@ -25,6 +25,12 @@ describe ValidatableForm do 
     | 
|
| 
       25 
25 
     | 
    
         
             
                f.name.should == "John Doe"
         
     | 
| 
       26 
26 
     | 
    
         
             
                f.email.should == "jdoe@example.com"
         
     | 
| 
       27 
27 
     | 
    
         
             
              end
         
     | 
| 
      
 28 
     | 
    
         
            +
             
     | 
| 
      
 29 
     | 
    
         
            +
              it "should allow initializing with nil attributes" do
         
     | 
| 
      
 30 
     | 
    
         
            +
                f = ContactForm.new(nil)    
         
     | 
| 
      
 31 
     | 
    
         
            +
                f.name.should be_nil
         
     | 
| 
      
 32 
     | 
    
         
            +
                f.email.should be_nil
         
     | 
| 
      
 33 
     | 
    
         
            +
              end
         
     | 
| 
       28 
34 
     | 
    
         | 
| 
       29 
35 
     | 
    
         
             
              it "should always be a new record" do
         
     | 
| 
       30 
36 
     | 
    
         
             
                ContactForm.new.should be_new_record
         
     | 
    
        metadata
    CHANGED
    
    | 
         @@ -1,7 +1,12 @@ 
     | 
|
| 
       1 
1 
     | 
    
         
             
            --- !ruby/object:Gem::Specification 
         
     | 
| 
       2 
2 
     | 
    
         
             
            name: validatable_form
         
     | 
| 
       3 
3 
     | 
    
         
             
            version: !ruby/object:Gem::Version 
         
     | 
| 
       4 
     | 
    
         
            -
               
     | 
| 
      
 4 
     | 
    
         
            +
              prerelease: false
         
     | 
| 
      
 5 
     | 
    
         
            +
              segments: 
         
     | 
| 
      
 6 
     | 
    
         
            +
              - 0
         
     | 
| 
      
 7 
     | 
    
         
            +
              - 0
         
     | 
| 
      
 8 
     | 
    
         
            +
              - 2
         
     | 
| 
      
 9 
     | 
    
         
            +
              version: 0.0.2
         
     | 
| 
       5 
10 
     | 
    
         
             
            platform: ruby
         
     | 
| 
       6 
11 
     | 
    
         
             
            authors: 
         
     | 
| 
       7 
12 
     | 
    
         
             
            - Geoffrey Dagley
         
     | 
| 
         @@ -14,24 +19,28 @@ default_executable: 
     | 
|
| 
       14 
19 
     | 
    
         
             
            dependencies: 
         
     | 
| 
       15 
20 
     | 
    
         
             
            - !ruby/object:Gem::Dependency 
         
     | 
| 
       16 
21 
     | 
    
         
             
              name: validatable
         
     | 
| 
       17 
     | 
    
         
            -
               
     | 
| 
       18 
     | 
    
         
            -
               
     | 
| 
       19 
     | 
    
         
            -
              version_requirements: !ruby/object:Gem::Requirement 
         
     | 
| 
      
 22 
     | 
    
         
            +
              prerelease: false
         
     | 
| 
      
 23 
     | 
    
         
            +
              requirement: &id001 !ruby/object:Gem::Requirement 
         
     | 
| 
       20 
24 
     | 
    
         
             
                requirements: 
         
     | 
| 
       21 
25 
     | 
    
         
             
                - - ">="
         
     | 
| 
       22 
26 
     | 
    
         
             
                  - !ruby/object:Gem::Version 
         
     | 
| 
      
 27 
     | 
    
         
            +
                    segments: 
         
     | 
| 
      
 28 
     | 
    
         
            +
                    - 0
         
     | 
| 
       23 
29 
     | 
    
         
             
                    version: "0"
         
     | 
| 
       24 
     | 
    
         
            -
             
     | 
| 
      
 30 
     | 
    
         
            +
              type: :runtime
         
     | 
| 
      
 31 
     | 
    
         
            +
              version_requirements: *id001
         
     | 
| 
       25 
32 
     | 
    
         
             
            - !ruby/object:Gem::Dependency 
         
     | 
| 
       26 
33 
     | 
    
         
             
              name: rspec
         
     | 
| 
       27 
     | 
    
         
            -
               
     | 
| 
       28 
     | 
    
         
            -
               
     | 
| 
       29 
     | 
    
         
            -
              version_requirements: !ruby/object:Gem::Requirement 
         
     | 
| 
      
 34 
     | 
    
         
            +
              prerelease: false
         
     | 
| 
      
 35 
     | 
    
         
            +
              requirement: &id002 !ruby/object:Gem::Requirement 
         
     | 
| 
       30 
36 
     | 
    
         
             
                requirements: 
         
     | 
| 
       31 
37 
     | 
    
         
             
                - - ">="
         
     | 
| 
       32 
38 
     | 
    
         
             
                  - !ruby/object:Gem::Version 
         
     | 
| 
      
 39 
     | 
    
         
            +
                    segments: 
         
     | 
| 
      
 40 
     | 
    
         
            +
                    - 0
         
     | 
| 
       33 
41 
     | 
    
         
             
                    version: "0"
         
     | 
| 
       34 
     | 
    
         
            -
             
     | 
| 
      
 42 
     | 
    
         
            +
              type: :development
         
     | 
| 
      
 43 
     | 
    
         
            +
              version_requirements: *id002
         
     | 
| 
       35 
44 
     | 
    
         
             
            description: 
         
     | 
| 
       36 
45 
     | 
    
         
             
            email: gdagley@gmail.com
         
     | 
| 
       37 
46 
     | 
    
         
             
            executables: []
         
     | 
| 
         @@ -64,18 +73,20 @@ required_ruby_version: !ruby/object:Gem::Requirement 
     | 
|
| 
       64 
73 
     | 
    
         
             
              requirements: 
         
     | 
| 
       65 
74 
     | 
    
         
             
              - - ">="
         
     | 
| 
       66 
75 
     | 
    
         
             
                - !ruby/object:Gem::Version 
         
     | 
| 
      
 76 
     | 
    
         
            +
                  segments: 
         
     | 
| 
      
 77 
     | 
    
         
            +
                  - 0
         
     | 
| 
       67 
78 
     | 
    
         
             
                  version: "0"
         
     | 
| 
       68 
     | 
    
         
            -
              version: 
         
     | 
| 
       69 
79 
     | 
    
         
             
            required_rubygems_version: !ruby/object:Gem::Requirement 
         
     | 
| 
       70 
80 
     | 
    
         
             
              requirements: 
         
     | 
| 
       71 
81 
     | 
    
         
             
              - - ">="
         
     | 
| 
       72 
82 
     | 
    
         
             
                - !ruby/object:Gem::Version 
         
     | 
| 
      
 83 
     | 
    
         
            +
                  segments: 
         
     | 
| 
      
 84 
     | 
    
         
            +
                  - 0
         
     | 
| 
       73 
85 
     | 
    
         
             
                  version: "0"
         
     | 
| 
       74 
     | 
    
         
            -
              version: 
         
     | 
| 
       75 
86 
     | 
    
         
             
            requirements: []
         
     | 
| 
       76 
87 
     | 
    
         | 
| 
       77 
88 
     | 
    
         
             
            rubyforge_project: 
         
     | 
| 
       78 
     | 
    
         
            -
            rubygems_version: 1.3. 
     | 
| 
      
 89 
     | 
    
         
            +
            rubygems_version: 1.3.6
         
     | 
| 
       79 
90 
     | 
    
         
             
            signing_key: 
         
     | 
| 
       80 
91 
     | 
    
         
             
            specification_version: 3
         
     | 
| 
       81 
92 
     | 
    
         
             
            summary: Create validatable, tableless models for forms without hacking ActiveRecord.
         
     |