toast 0.1.1 → 0.2.0
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/lib/toast/associate_collection.rb +2 -0
 - data/lib/toast/attribute.rb +2 -0
 - data/lib/toast/config_dsl.rb +10 -1
 - data/lib/toast/record.rb +4 -1
 - data/lib/toast/resource.rb +3 -0
 - data/lib/toast/root_collection.rb +2 -0
 - metadata +4 -4
 
    
        data/lib/toast/attribute.rb
    CHANGED
    
    
    
        data/lib/toast/config_dsl.rb
    CHANGED
    
    | 
         @@ -12,6 +12,7 @@ module Toast 
     | 
|
| 
       12 
12 
     | 
    
         
             
                    @media_type = "application/json"
         
     | 
| 
       13 
13 
     | 
    
         
             
                    @exposed_attributes = []
         
     | 
| 
       14 
14 
     | 
    
         
             
                    @exposed_associations = []
         
     | 
| 
      
 15 
     | 
    
         
            +
                    @disallow_methods = []
         
     | 
| 
       15 
16 
     | 
    
         
             
                    @in_collection = ConfigDSL::InCollection.new model, self
         
     | 
| 
       16 
17 
     | 
    
         
             
                  end
         
     | 
| 
       17 
18 
     | 
    
         | 
| 
         @@ -24,7 +25,6 @@ module Toast 
     | 
|
| 
       24 
25 
     | 
    
         
             
                        @exposed_associations << attr_or_assoc
         
     | 
| 
       25 
26 
     | 
    
         
             
                      end
         
     | 
| 
       26 
27 
     | 
    
         
             
                    end
         
     | 
| 
       27 
     | 
    
         
            -
             
     | 
| 
       28 
28 
     | 
    
         
             
                  end
         
     | 
| 
       29 
29 
     | 
    
         | 
| 
       30 
30 
     | 
    
         
             
                  def fields *arg
         
     | 
| 
         @@ -32,6 +32,15 @@ module Toast 
     | 
|
| 
       32 
32 
     | 
    
         
             
                    self.fields = *arg
         
     | 
| 
       33 
33 
     | 
    
         
             
                  end
         
     | 
| 
       34 
34 
     | 
    
         | 
| 
      
 35 
     | 
    
         
            +
                  def disallow_methods= *arg
         
     | 
| 
      
 36 
     | 
    
         
            +
                    @disallow_methods.push *ConfigDSL.sanitize(arg,"disallow methods")
         
     | 
| 
      
 37 
     | 
    
         
            +
                  end
         
     | 
| 
      
 38 
     | 
    
         
            +
             
     | 
| 
      
 39 
     | 
    
         
            +
                  def disallow_methods *arg
         
     | 
| 
      
 40 
     | 
    
         
            +
                    return(@disallow_methods) if arg.empty?
         
     | 
| 
      
 41 
     | 
    
         
            +
                    self.disallow_methods = *arg        
         
     | 
| 
      
 42 
     | 
    
         
            +
                  end
         
     | 
| 
      
 43 
     | 
    
         
            +
             
     | 
| 
       35 
44 
     | 
    
         
             
                  attr_reader :exposed_attributes, :exposed_associations
         
     | 
| 
       36 
45 
     | 
    
         | 
| 
       37 
46 
     | 
    
         
             
                  def collections= collections=[]
         
     | 
    
        data/lib/toast/record.rb
    CHANGED
    
    | 
         @@ -1,5 +1,7 @@ 
     | 
|
| 
       1 
1 
     | 
    
         
             
            module Toast
         
     | 
| 
       2 
2 
     | 
    
         
             
              class Record < Resource
         
     | 
| 
      
 3 
     | 
    
         
            +
             
     | 
| 
      
 4 
     | 
    
         
            +
                attr_reader :model
         
     | 
| 
       3 
5 
     | 
    
         | 
| 
       4 
6 
     | 
    
         
             
                def initialize model, id
         
     | 
| 
       5 
7 
     | 
    
         
             
                  @model = model      
         
     | 
| 
         @@ -27,7 +29,7 @@ module Toast 
     | 
|
| 
       27 
29 
     | 
    
         
             
                  end
         
     | 
| 
       28 
30 
     | 
    
         | 
| 
       29 
31 
     | 
    
         
             
                  @record.update_attributes payload
         
     | 
| 
       30 
     | 
    
         
            -
             
     | 
| 
      
 32 
     | 
    
         
            +
                 { 
         
     | 
| 
       31 
33 
     | 
    
         
             
                    :json => @record.exposed_attributes,
         
     | 
| 
       32 
34 
     | 
    
         
             
                    :status => :ok,
         
     | 
| 
       33 
35 
     | 
    
         
             
                    :location => @record.uri
         
     | 
| 
         @@ -44,6 +46,7 @@ module Toast 
     | 
|
| 
       44 
46 
     | 
    
         
             
                def delete
         
     | 
| 
       45 
47 
     | 
    
         
             
                  @record.destroy
         
     | 
| 
       46 
48 
     | 
    
         
             
                  {
         
     | 
| 
      
 49 
     | 
    
         
            +
                    :nothing => true,
         
     | 
| 
       47 
50 
     | 
    
         
             
                    :status => :ok
         
     | 
| 
       48 
51 
     | 
    
         
             
                  }
         
     | 
| 
       49 
52 
     | 
    
         
             
                end
         
     | 
    
        data/lib/toast/resource.rb
    CHANGED
    
    
    
        metadata
    CHANGED
    
    | 
         @@ -1,13 +1,13 @@ 
     | 
|
| 
       1 
1 
     | 
    
         
             
            --- !ruby/object:Gem::Specification 
         
     | 
| 
       2 
2 
     | 
    
         
             
            name: toast
         
     | 
| 
       3 
3 
     | 
    
         
             
            version: !ruby/object:Gem::Version 
         
     | 
| 
       4 
     | 
    
         
            -
              hash:  
     | 
| 
      
 4 
     | 
    
         
            +
              hash: 23
         
     | 
| 
       5 
5 
     | 
    
         
             
              prerelease: 
         
     | 
| 
       6 
6 
     | 
    
         
             
              segments: 
         
     | 
| 
       7 
7 
     | 
    
         
             
              - 0
         
     | 
| 
       8 
     | 
    
         
            -
              -  
     | 
| 
       9 
     | 
    
         
            -
              -  
     | 
| 
       10 
     | 
    
         
            -
              version: 0. 
     | 
| 
      
 8 
     | 
    
         
            +
              - 2
         
     | 
| 
      
 9 
     | 
    
         
            +
              - 0
         
     | 
| 
      
 10 
     | 
    
         
            +
              version: 0.2.0
         
     | 
| 
       11 
11 
     | 
    
         
             
            platform: ruby
         
     | 
| 
       12 
12 
     | 
    
         
             
            authors: 
         
     | 
| 
       13 
13 
     | 
    
         
             
            - Robert Annies
         
     |