Class: SimpleJsonapi::Definition::Link
- Defined in:
- lib/simple_jsonapi/definition/link.rb
Overview
Represents a single member in a links
object
Instance Attribute Summary collapse
- #name ⇒ Symbol readonly
Instance Method Summary collapse
-
#initialize(name, *args, **options) {|object| ... } ⇒ Link
constructor
A new instance of Link.
Constructor Details
#initialize(name, options = {}, &block) ⇒ Link #initialize(name, value, options = {}) ⇒ Link
Returns a new instance of Link.
14 15 16 17 18 19 20 |
# File 'lib/simple_jsonapi/definition/link.rb', line 14 def initialize(name, *args, **, &block) raise ArgumentError, "A name is required" if name.blank? super @name = name @value_proc = wrap_in_proc(*args, &block) end |
Instance Attribute Details
#name ⇒ Symbol (readonly)
4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 |
# File 'lib/simple_jsonapi/definition/link.rb', line 4 class SimpleJsonapi::Definition::Link < SimpleJsonapi::Definition::Base attr_reader :name # @visibility private attr_reader :value_proc # @overload initialize(name, options = {}, &block) # @overload initialize(name, value, options = {}) # @yieldparam object [Object] The resource or error. # @yieldreturn [String,Hash] The link or link object. # @option (see Definition::Base#initialize) def initialize(name, *args, **, &block) raise ArgumentError, "A name is required" if name.blank? super @name = name @value_proc = wrap_in_proc(*args, &block) end private def initialize_dup(new_def) super # name is a symbol, can't be duped new_def.instance_variable_set(:@value_proc, @value_proc.dup) end end |