Module: JSONAPI::Param::ClassMethods
- Defined in:
- lib/jsonapi-params/param.rb
Instance Attribute Summary collapse
-
#whitelist_attributes ⇒ Object
Returns the value of attribute whitelist_attributes.
-
#whitelist_relationships ⇒ Object
Returns the value of attribute whitelist_relationships.
Instance Method Summary collapse
-
#belongs_to(relationship_name) ⇒ nil
Adds a relationship one-to-one to whitelist of relationships.
-
#param(name) ⇒ nil
Adds the parameters to whitelist of parameters.
-
#params(*names) ⇒ nil
Adds a list of parameters to whitelist of parameters.
Instance Attribute Details
#whitelist_attributes ⇒ Object
Returns the value of attribute whitelist_attributes.
12 13 14 |
# File 'lib/jsonapi-params/param.rb', line 12 def whitelist_attributes @whitelist_attributes end |
#whitelist_relationships ⇒ Object
Returns the value of attribute whitelist_relationships.
12 13 14 |
# File 'lib/jsonapi-params/param.rb', line 12 def whitelist_relationships @whitelist_relationships end |
Instance Method Details
#belongs_to(relationship_name) ⇒ nil
Adds a relationship one-to-one to whitelist of relationships
34 35 36 37 38 39 40 |
# File 'lib/jsonapi-params/param.rb', line 34 def belongs_to(relationship_name) relationship_name = relationship_name.to_s @whitelist_relationships ||= [] @whitelist_relationships << relationship_name.dasherize @whitelist_relationships << relationship_name.underscore unless @whitelist_relationships.include?(relationship_name.underscore) end |
#param(name) ⇒ nil
Adds the parameters to whitelist of parameters
18 19 20 |
# File 'lib/jsonapi-params/param.rb', line 18 def param(name) add_param(name) end |
#params(*names) ⇒ nil
Adds a list of parameters to whitelist of parameters
26 27 28 |
# File 'lib/jsonapi-params/param.rb', line 26 def params(*names) names.each { |name| add_param(name) } end |