Sha256: 21d337b9e1a9175a4b52aa4e44b0173933745299131aa59b4e7eb94b6d3d22c6
Contents?: true
Size: 738 Bytes
Versions: 2
Compression:
Stored size: 738 Bytes
Contents
# Duck-type some helper class methods into our ActiveRecord models to # allow us to configure API behaviors granularly, at the model level. class ActiveRecord::Base class << self @@api_actions ||= [:index,:show,:create,:update,:destroy,nil] def api_actions; @@api_actions; end def exclude_actions(*args) # Do not define endpoints for these actions raise "#{self.name} defines invalid exclude_actions: #{args-@@api_actions}" if (args.flatten-@@api_actions).present? @exclude_actions = args.present? ? args.flatten : @exclude_actions || [] end def default_includes(*args) # Eager load these associations. @default_includes = args.present? ? args.flatten : @default_includes || [] end end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
introspective_grape-0.0.4 | spec/dummy/app/api/active_record_helpers.rb |
introspective_grape-0.0.3 | spec/dummy/app/api/active_record_helpers.rb |