Class: Swagger::Grape::EntityExposure
- Inherits:
- 
      Object
      
        - Object
- Swagger::Grape::EntityExposure
 
- Defined in:
- lib/ruby-swagger/grape/entity_exposure.rb
Direct Known Subclasses
Instance Method Summary collapse
- #array? ⇒ Boolean
- #attribute ⇒ Object
- #description ⇒ Object
- #documentation ⇒ Object
- 
  
    
      #initialize(exposure)  ⇒ EntityExposure 
    
    
  
  
  
    constructor
  
  
  
  
  
  
  
    A new instance of EntityExposure. 
- #nested? ⇒ Boolean
- #nested_exposures ⇒ Object
- #options ⇒ Object
- #representer? ⇒ Boolean
- #sub_type ⇒ Object
- #to_swagger ⇒ Object
- #type ⇒ Object
- #type? ⇒ Boolean
Constructor Details
#initialize(exposure) ⇒ EntityExposure
Returns a new instance of EntityExposure.
| 3 4 5 6 7 8 | # File 'lib/ruby-swagger/grape/entity_exposure.rb', line 3 def initialize(exposure) raise ArgumentError.new("Expecting a Grape::Entity::Exposure - Can't translate #{exposure}!") unless exposure.is_a? Grape::Entity::Exposure::Base @exposure = exposure @swagger_type = { attribute => {} } end | 
Instance Method Details
#array? ⇒ Boolean
| 22 23 24 | # File 'lib/ruby-swagger/grape/entity_exposure.rb', line 22 def array? type == 'array' end | 
#attribute ⇒ Object
| 42 43 44 | # File 'lib/ruby-swagger/grape/entity_exposure.rb', line 42 def attribute [:as].present? ? [:as].to_s : @exposure.attribute.to_s end | 
#description ⇒ Object
| 58 59 60 | # File 'lib/ruby-swagger/grape/entity_exposure.rb', line 58 def description @exposure.documentation[:desc] if @exposure.documentation[:desc].present? end | 
#documentation ⇒ Object
| 52 53 54 55 56 | # File 'lib/ruby-swagger/grape/entity_exposure.rb', line 52 def documentation @exposure.documentation || {} rescue {} end | 
#nested? ⇒ Boolean
| 18 19 20 | # File 'lib/ruby-swagger/grape/entity_exposure.rb', line 18 def nested? [:nesting] || false end | 
#nested_exposures ⇒ Object
| 34 35 36 | # File 'lib/ruby-swagger/grape/entity_exposure.rb', line 34 def nested_exposures nested? ? @exposure.nested_exposures : nil end | 
#options ⇒ Object
| 46 47 48 49 50 | # File 'lib/ruby-swagger/grape/entity_exposure.rb', line 46 def @exposure.send(:options) rescue {} end | 
#representer? ⇒ Boolean
| 26 27 28 | # File 'lib/ruby-swagger/grape/entity_exposure.rb', line 26 def representer? @exposure.is_a? Grape::Entity::Exposure::RepresentExposure end | 
#sub_type ⇒ Object
| 14 15 16 | # File 'lib/ruby-swagger/grape/entity_exposure.rb', line 14 def sub_type [:using] if representer? end | 
#to_swagger ⇒ Object
| 10 11 12 | # File 'lib/ruby-swagger/grape/entity_exposure.rb', line 10 def to_swagger translate end | 
#type ⇒ Object
| 38 39 40 | # File 'lib/ruby-swagger/grape/entity_exposure.rb', line 38 def type documentation[:type].to_s.downcase if documentation[:type].present? end | 
#type? ⇒ Boolean
| 30 31 32 | # File 'lib/ruby-swagger/grape/entity_exposure.rb', line 30 def type? type.present? end |