Rhino Resource Properties

Provides a way to control what properties are exposed on resources as well as an interface for resource implementations to implement and existence utilities.

Read, create and update properties can be constrained with only and except directives:

class User
  include ActiveModel::AttributeMethods

  rhino_properties_read except: :password
  rhino_properties_create only: [:email]
  rhino_properties_update only: [:name]
end

rhino_properties_write constrains both create and update.

Resource implementations need to implement the following methods:

identifier_property
readable_properties
creatable_properties
updatable_properties
Methods
A
C
D
I
P
R
U
Instance Public methods
all_properties()
    # File rhino/rhino/lib/rhino/resource/properties.rb
166 def all_properties
167   self._all_properties = (read_properties + create_properties + update_properties).uniq.map(&:to_s) unless self._all_properties
168 
169   self._all_properties
170 end
creatable_properties()
    # File rhino/rhino/lib/rhino/resource/properties.rb
 98 def creatable_properties
 99   raise NotImplementedError, '#creatable_properties is not implemented'
100 end
create_properties()

Return list of create properties for the resource

    # File rhino/rhino/lib/rhino/resource/properties.rb
129 def create_properties
130   unless self._create_properties
131     # If create only was set, use that
132     return self._create_properties_only if self._create_properties_only
133 
134     self._create_properties = creatable_properties.select do |property|
135       self._create_properties_except.exclude?(property)
136     end
137   end
138 
139   self._create_properties
140 end
create_property?(property)

Check if create property exists

    # File rhino/rhino/lib/rhino/resource/properties.rb
143 def create_property?(property)
144   create_properties.include?(property)
145 end
describe_property()
    # File rhino/rhino/lib/rhino/resource/properties.rb
177 def describe_property
178   raise NotImplementedError, '#describe_property is not implemented'
179 end
identifier_property()
   # File rhino/rhino/lib/rhino/resource/properties.rb
90 def identifier_property
91   raise NotImplementedError, '#identifier_property is not implemented'
92 end
property?(property)

Check if property exists

    # File rhino/rhino/lib/rhino/resource/properties.rb
173 def property?(property)
174   all_properties.include?(property)
175 end
read_properties()

Return list of read properties for the resource (show and index)

    # File rhino/rhino/lib/rhino/resource/properties.rb
107 def read_properties
108   # If :only was not set explicitly, select only the default includables
109   # and extended models, leaving out the excepted models
110   unless self._read_properties
111     # If only was set, use that
112     return self._read_properties_only if self._read_properties_only
113 
114     self._read_properties = readable_properties.select do |property|
115       # And its not excepted
116       self._read_properties_except.exclude?(property)
117     end
118   end
119 
120   self._read_properties
121 end
read_property?(property)

Check if read property exists

    # File rhino/rhino/lib/rhino/resource/properties.rb
124 def read_property?(property)
125   read_properties.include?(property)
126 end
readable_properties()
   # File rhino/rhino/lib/rhino/resource/properties.rb
94 def readable_properties
95   raise NotImplementedError, '#readable_properties is not implemented'
96 end
rhino_properties_array(options)
   # File rhino/rhino/lib/rhino/resource/properties.rb
86 def rhino_properties_array(options)
87   self._properties_array = options
88 end
rhino_properties_create(**options)
   # File rhino/rhino/lib/rhino/resource/properties.rb
64 def rhino_properties_create(**options)
65   self._create_properties_only = Array.wrap(options[:only]).map(&:to_s) if options.key?(:only)
66   self._create_properties_except = Array.wrap(options[:except]).map(&:to_s) if options.key?(:except)
67 end
rhino_properties_format(format)
   # File rhino/rhino/lib/rhino/resource/properties.rb
82 def rhino_properties_format(format)
83   self._properties_format = format
84 end
rhino_properties_read(**options)
   # File rhino/rhino/lib/rhino/resource/properties.rb
59 def rhino_properties_read(**options)
60   self._read_properties_only = Array.wrap(options[:only]).map(&:to_s) if options.key?(:only)
61   self._read_properties_except = Array.wrap(options[:except]).map(&:to_s) if options.key?(:except)
62 end
rhino_properties_update(**options)
   # File rhino/rhino/lib/rhino/resource/properties.rb
69 def rhino_properties_update(**options)
70   self._update_properties_only = Array.wrap(options[:only]).map(&:to_s) if options.key?(:only)
71   self._update_properties_except = Array.wrap(options[:except]).map(&:to_s) if options.key?(:except)
72 end
rhino_properties_write(...)

Constrain create and update properties Accepts only: and except: as either a single property or an array of properties

   # File rhino/rhino/lib/rhino/resource/properties.rb
77 def rhino_properties_write(...)
78   rhino_properties_create(...)
79   rhino_properties_update(...)
80 end
updatable_properties()
    # File rhino/rhino/lib/rhino/resource/properties.rb
102 def updatable_properties
103   raise NotImplementedError, '#updatable_properties is not implemented'
104 end
update_properties()

Return list of update properties for the resource

    # File rhino/rhino/lib/rhino/resource/properties.rb
148 def update_properties
149   unless self._update_properties
150     # If update only was set, use that
151     return self._update_properties_only if self._update_properties_only
152 
153     self._update_properties = updatable_properties.select do |property|
154       self._update_properties_except.exclude?(property)
155     end
156   end
157 
158   self._update_properties
159 end
update_property?(property)

Check if update property exists

    # File rhino/rhino/lib/rhino/resource/properties.rb
162 def update_property?(property)
163   update_properties.include?(property)
164 end