Sha256: 390c59ab634fc88822003f3e0b9cbb913b7c19370aa1e493a077d48563a7fbe6
Contents?: true
Size: 520 Bytes
Versions: 2
Compression:
Stored size: 520 Bytes
Contents
# Define attributes which can be assigned & read, or # "defined", by passing the new value as an argument # # @example defining an object's name # object.name("New name") # module GraphQL::DefinitionHelpers::Definable def attr_definable(*names) attr_accessor(*names) names.each do |name| ivar_name = "@#{name}".to_sym define_method(name) do |new_value=nil| new_value && self.instance_variable_set(ivar_name, new_value) instance_variable_get(ivar_name) end end end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
graphql-0.5.0 | lib/graph_ql/definition_helpers/definable.rb |
graphql-0.4.0 | lib/graph_ql/definition_helpers/definable.rb |