Module: RESTFramework::ClassMethodHelpers

Included in:
BaseControllerMixin::ClassMethods, BaseModelControllerMixin::ClassMethods
Defined in:
lib/rest_framework/controllers/base.rb

Overview

This module provides helpers for mixin ‘ClassMethods` submodules.

Instance Method Summary collapse

Instance Method Details

#_restframework_attr_reader(property, default: nil) ⇒ Object

This helper assists in providing reader interfaces for mixin properties.



7
8
9
10
11
12
13
14
15
16
17
# File 'lib/rest_framework/controllers/base.rb', line 7

def _restframework_attr_reader(property, default: nil)
  method = <<~RUBY
    def #{property}
      return _restframework_try_class_level_variable_get(
        #{property.inspect},
        default: #{default.inspect},
      )
    end
  RUBY
  self.module_eval(method)
end