Class: ActiveFedora::Reflection::MacroReflection
- Inherits:
-
AbstractReflection
- Object
- AbstractReflection
- ActiveFedora::Reflection::MacroReflection
- Defined in:
- lib/active_fedora/reflection.rb
Direct Known Subclasses
Instance Attribute Summary collapse
-
#active_fedora ⇒ Object
readonly
Returns the value of attribute active_fedora.
-
#name ⇒ Object
readonly
Returns the name of the macro.
-
#options ⇒ Object
readonly
Returns the hash of options used for the macro.
-
#scope ⇒ Object
readonly
Returns the value of attribute scope.
Instance Method Summary collapse
-
#==(other) ⇒ Object
Returns
true
ifself
andother_aggregation
have the samename
attribute,active_record
attribute, andother_aggregation
has an options hash assigned to it. -
#autosave=(autosave) ⇒ Object
rubocop:enable Lint/MissingSuper.
- #compute_class(name) ⇒ Object
-
#initialize(name, scope, options, active_fedora) ⇒ MacroReflection
constructor
rubocop:disable Lint/MissingSuper.
-
#klass ⇒ Object
Returns the class for the macro.
Methods inherited from AbstractReflection
#alias_candidate, #build_association, #chain, #check_validity_of_inverse!, #class_name, #constraints, #inverse_of, #through_reflection?
Constructor Details
#initialize(name, scope, options, active_fedora) ⇒ MacroReflection
rubocop:disable Lint/MissingSuper
215 216 217 218 219 220 221 222 |
# File 'lib/active_fedora/reflection.rb', line 215 def initialize(name, scope, , active_fedora) @name = name @scope = scope @options = @active_fedora = active_fedora @klass = [:anonymous_class] @automatic_inverse_of = nil end |
Instance Attribute Details
#active_fedora ⇒ Object (readonly)
Returns the value of attribute active_fedora.
212 213 214 |
# File 'lib/active_fedora/reflection.rb', line 212 def active_fedora @active_fedora end |
#name ⇒ Object (readonly)
Returns the name of the macro.
has_many :clients
returns :clients
203 204 205 |
# File 'lib/active_fedora/reflection.rb', line 203 def name @name end |
#options ⇒ Object (readonly)
Returns the hash of options used for the macro.
has_many :clients
returns {}
210 211 212 |
# File 'lib/active_fedora/reflection.rb', line 210 def @options end |
#scope ⇒ Object (readonly)
Returns the value of attribute scope.
205 206 207 |
# File 'lib/active_fedora/reflection.rb', line 205 def scope @scope end |
Instance Method Details
#==(other) ⇒ Object
Returns true
if self
and other_aggregation
have the same name
attribute, active_record
attribute, and other_aggregation
has an options hash assigned to it.
245 246 247 248 249 250 251 |
# File 'lib/active_fedora/reflection.rb', line 245 def ==(other) super || other.is_a?(self.class) && name == other.name && !other..nil? && active_record == other.active_record end |
#autosave=(autosave) ⇒ Object
rubocop:enable Lint/MissingSuper
225 226 227 228 229 |
# File 'lib/active_fedora/reflection.rb', line 225 def autosave=(autosave) @options[:autosave] = autosave parent_reflection = self.parent_reflection parent_reflection.autosave = autosave if parent_reflection end |
#compute_class(name) ⇒ Object
239 240 241 |
# File 'lib/active_fedora/reflection.rb', line 239 def compute_class(name) name.constantize end |
#klass ⇒ Object
Returns the class for the macro.
composed_of :balance, class_name: 'Money'
returns the Money class has_many :clients
returns the Client class
235 236 237 |
# File 'lib/active_fedora/reflection.rb', line 235 def klass @klass ||= compute_class(class_name) end |