Class: RailsApiDoc::Controller::Param
- Inherits:
-
Object
- Object
- RailsApiDoc::Controller::Param
- Defined in:
- lib/rails_api_doc/controller/param.rb
Direct Known Subclasses
Constant Summary collapse
- COMMON_VALID_KEYS =
:nodoc:
[:type, :model, :desc, :id, :nested, :action_type].freeze
- VALID_REQUEST_KEYS =
[:required, :enum, :value].freeze
- VALID_RESPONSE_KEYS =
[:attr].freeze
- VALID_KEYS =
(COMMON_VALID_KEYS + VALID_REQUEST_KEYS + VALID_RESPONSE_KEYS).freeze
- HELPER_KEYS =
[:new, :is_new, :param, :name, :store].freeze
Class Method Summary collapse
Instance Method Summary collapse
- #add_updated_field(field) ⇒ Object
- #created? ⇒ Boolean
-
#destroyed? ⇒ Boolean
these are actions applied to the params by gem user from frontend.
-
#display_name ⇒ Object
redefined in descendants.
-
#display_special ⇒ Object
redefined in descendants.
-
#display_type ⇒ Object
redefine to get desired behaviour.
-
#display_value ⇒ Object
redefined in descendants.
- #updated? ⇒ Boolean
Class Method Details
.define_accessors(*accessors) ⇒ Object
30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 |
# File 'lib/rails_api_doc/controller/param.rb', line 30 def self.define_accessors(*accessors) accessors.each do |acc| define_method acc do @store[acc] end define_method "#{acc}?" do @store[acc].present? end define_method "#{acc}=" do |val| @store[acc] = val end end end |
Instance Method Details
#add_updated_field(field) ⇒ Object
73 74 75 |
# File 'lib/rails_api_doc/controller/param.rb', line 73 def add_updated_field(field) @new.push(field) unless field.in?(@new) end |
#created? ⇒ Boolean
65 66 67 |
# File 'lib/rails_api_doc/controller/param.rb', line 65 def created? param&.action_type == 'create' end |
#destroyed? ⇒ Boolean
these are actions applied to the params by gem user from frontend
61 62 63 |
# File 'lib/rails_api_doc/controller/param.rb', line 61 def destroyed? param&.action_type == 'destroy' end |
#display_name ⇒ Object
redefined in descendants
101 102 103 |
# File 'lib/rails_api_doc/controller/param.rb', line 101 def display_name @name end |
#display_special ⇒ Object
redefined in descendants
95 96 |
# File 'lib/rails_api_doc/controller/param.rb', line 95 def display_special end |
#display_type ⇒ Object
redefine to get desired behaviour
80 81 82 83 84 85 86 87 88 89 90 |
# File 'lib/rails_api_doc/controller/param.rb', line 80 def display_type t = if nested? (model || type).to_s + '(Nested)' else type.to_s end t += "(#{param.type})" if param && param.type != type t end |
#display_value ⇒ Object
redefined in descendants
108 109 |
# File 'lib/rails_api_doc/controller/param.rb', line 108 def display_value end |
#updated? ⇒ Boolean
69 70 71 |
# File 'lib/rails_api_doc/controller/param.rb', line 69 def updated? param&.action_type == 'update' end |